The following is from Learn clojure in Y minutes.
; Comments start with semicolons.
Clojure is written in forms.
forms - lists of things inside parentheses, separated by whitespace
Assume:
- The first thing is a function or macro to call.
- The rest are arguments.
The first call in a file should be "ns" to set the namespace:
> (ns learnclojure)
To create a string:
(str "Hello" " " "World")
Math uses prefix notation.
> (+ 1 1) 2 > (- 2 1) 1 > (* 2 2) 4 > (/ 2 1) 2
Unlike Java or JavaScript, equality is just a single equals:
> (= 1 1) true > (= 0 1) false
The negation operator is "not":
> (not true) false
Nested arithmetic operations use the normal PEMDAS order of operations convention:
> (/ 14 (+ 3 4)) 2