Always easier to remember things when you write them down :).
Syntax
Operations follow this pattern:
1
| |
No commas between operands, just whitespace.
Clojure uses prefix notation as opposed to infix notation which is more familiar in other languages
1 2 | |
Equality
1 2 3 4 5 6 | |
Strings
Use double quotes to delineate strings, e.g. : "This is a string"
For concatenation use str function:
1 2 3 | |
Maps
Map values can be of any type and can be nested.
1 2 3 | |
Use get to look up values and get-in to look up values in nested maps. Instead of get you can treat it as a function with the key as a parameter.
1 2 3 4 5 6 7 8 9 10 | |
Keywords
In these examples :first is a keyword. Key words can be used as functions:
1 2 | |
Vectors
Think array in other languages. Elements of a Vector can be of any type and you can retrieve values using get as well.
1 2 3 | |
Can also be created using vector function:
1 2 | |
Using conj you add elements to a vector. Elements get added to the end of a vector.
Lists
Like vectors, however you can’t use get to retrieve values. Use nth instead
1 2 3 | |
Lists can be created using the list function. Use conj to add items to a list. Unlike vectors they get added to the beginning of the list.
Sets
Collection of unique values. Created either using #{} or set.
1 2 | |
Use get to retrieve values. You can create sets using hash-set or sorted-set as well:
1 2 3 4 | |
Symbols
Another assignment method, however apparently we can manipulate them as if they were data. Not sure what that means yet.
Quoting
' is referred to as quoting. Used this to define a list. Used in macros.