(function arg1 arg2 ... argn) (1 2 3) ; A number cannot be cast to a function (str "Hello" " " "World") ; "Hello World"
(= :a :a) ; true (:a (hash-map :a 3)) ; 3 ((hash-map :a 3) :a) ; 3
(def i 2) (defn g [name] (str "Hello " name))
{:a 1 :b 7} ; Maps `(1 2 3) ; Lists [1 2 3] ; Vectors #{1 2 3} ; Sets
;; three ways to write the same thing #(dec %) (fn [n] (dec n)) (fn subtract-one [n] (dec n)) (#(dec %) 1) ; 0 ((fn [n] (dec n)) 1) ; 0 ((fn subtract-one [n] (dec n)) 1) ; 0
(map #(dec %) [1 2]) ; (0 1) (map (fn [n] (dec n)) [1 2]) ; (0 1) (map (fn subtract-one [n] (dec n)) [1 2]) ; (0 1)
(-> object # to the left .setProperty 5 .toString) (->> [] # to the right cons 1 cons 2 str) ; "21"
quote ', unquote ~, unquote-splicing ~@
(defn next-step [count] (inc count)) (next-step 3) ; 4
(def count (atom 1)) (defn next-step [count] (inc @count)) (next-step 3) ; 4 (deref count) ; 3
(def count (atom 1)) (defn next-step [count] (swap! count inc)) (next-step 3) ; 4 (deref count) ; 4