Introduction to S-Expressions and Lists in Atom
Classified in Physics
Written on in
English with a size of 3.92 KB
- Atom is pretty much just a string of characters with no spaces
- Atom --> atom
- Atom123 --> atom
- ( ) --> NOT an atom, it’s actually a list
All atoms are S-expressions
A list is enclosed in parenthesis
All lists are S-expressions too
- (how are you doing) --> List
- (atom) --> a list because its an atom enclosed by parentheses
- ( ) --> List
The car of an argument is the first S-Expression in something
- The car of j where j is ((a b c) x y z) = (a b c)
- The car of j where j is hotdog doesn’t exist because you can’t ask for the car of an atom
- The (car (car j)) where j is (((hotdogs)) (and)) = (hotdogs)
The cdr of an argument is anything that follows the car of an argument
- The cdr of j where j is (a b c) = (b c)
- The cdr of j where j is ((a b c) x