Learning Clojure
; Comments start with semicolons.
; Clojure is written in “form”, which are just
;lists of things inside parentheses, separated by white space.
; The clojure reader assumes that the firs tthing is a
; function or macro to call, and the rest are arguments.
;the first call in a file should be ns, to set the namespace
(ns learnclojure)
; More basic examples:
; str will create a string out of all its arguments
(str “Hello” “ “ “World”) ; => “Hello World”
(str “This” “ “ “is” “ “ “a” “ “ “String”) ; => “This is a String”
; Math is straightforward
(+ 1 1) ; => 2
(- 2 1) ; => 1
(* 1 2) ; => 2
(/ 2 1) ; => 2
; Equality is =
(= 1 1) ; => true
(= 2 1) ; => false
; you need not for logic, too
(not true) ; => false
; Nesting forms works as you expect
(+ 1 (- 3 2)) ; => 1 + (3–2)