(let [a (atom 0) b (fn [] (swap! a inc))] [(b) (b) (b)])
[1 2 3]
(let [xs (cons 1 (lazy-seq (println "forced") '(2)))] (rest xs) :foo)
:foo(let [x 5 inner `(foo bar ~x)] `(do ~x ~inner))
(do 5 (user/foo user/bar 5))
(let [vec [1 2 3 4]] (subvec vec 1 (dec (count vec))))
[2 3]
(let [v [:a :b :c] f name] (zipmap v (map f v)))
{:a "a", :b "b", :c "c"}
(let [a {:a :b, :c :d}] (str (seq (map reverse (into [] a)))))
"((:b :a) (:d :c))"(defmacro d [name] `(let [result# ~name] (println '~name "=" result#) result#))
#'user/d
(let [m {:a "1", :b "2"}] [m (pr-str m) (read-string (pr-str m))])
[{:a "1", :b "2"} "{:a \"1\", :b \"2\"}" {:a "1", :b "2"}]
(let [cool (fn cool [a b] (+ a b))] (cool 4 5))
9(let [x (apply concat (repeatedly #(do (print "X") (repeat 60 1))))])
nil"XXXX"(let [{a 1, b 2} '(1 2 3 4)] [a b])
[2 nil]
(let [points [1 2 3]] (map #(get points %) [1 2]))
(2 3)
(let [x [1 2 3]] [(into x [4]) (into x [5]) x])
[[1 2 3 4] [1 2 3 5] [1 2 3]]
(let [x '(2) y (cons 1 x)] (identical? x (rest y)))
true(defmacro cast-null [c] `(let [~(with-meta 'x {:tag c}) nil] ~'x))
#'user/cast-null
(let [a (hash-map Double/NaN 1)] (identical? (key (first a)) (key (first a))))
true(let [n 1] (println n) (println "this is the return >") n)
1"1\nthis is the return >\n"(let [agh (identity Double/NaN) hm Double/NaN] [(= agh agh) (= hm hm)])
[true true]
(let [vs (clojure.string/split "1,2,3,4,5,6,7" #",")] (println (nth vs 0) (nth vs 5)))
nil"1 6\n"(let [x (apply concat (repeatedly #(do (print "X") [1 2 3])))])
nil"XXXX"(let [a '(1 2 3) b (cons 4 a)] [a b])
[(1 2 3) (4 1 2 3)]
(let [n {:polarity :+}] (condp = (:polarity n) :+ "positive" :- "negative"))
"positive"(let [name "x" names `(name ~name)] (for [n names] (println n)))
(nil nil)
"clojure.core/name\nx\n"(let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner))
(do 5 (foo bar 5))
(let [nana Double/NaN] [(.equals nana nana) (= nana nana) (== nana nana)])
[true true false]
(let [boolean? (some-fn true? false?)] (map boolean? [true false :a 1 "ten"]))
(true true false false false)
(defmacro pred-let [cond bindings & body] `(when ~cond (let ~bindings ~@body)))
#'user/pred-let
(let [my-order [:b :c]] (map {:a 1, :b 2, :c 3} my-order))
(2 3)
(let [y [{:a "a", :b "b"}]] (into (into (into [] [y]) [y]) [y]))
[[{:a "a", :b "b"}] [{:a "a", :b "b"}] [{:a "a", :b "b"}]]
(defmacro awhen [expr & body] `(let [~'it ~expr] (when ~expr ~@body)))
#'user/awhen
(let [v [11 22 33 44] indices [1 3]] (mapv v indices))
[22 44]
(defmacro cache [exp] (let [sym (gensym)] (eval `(def ~sym ~exp)) sym))
#'user/cache
(let [s "11,222,3333"] (reduce + (read-string (str "[" s "]"))))
3566(let [req {:params {:a 5, :b 8}}] (assoc-in req [:params :c] 42))
{:params {:a 5, :b 8, :c 42}}
(let [x 1 #_#_x (+ x 2) x (+ x 4)] x)
5(let [syms (map symbol (seq (.split "a,b,c,d" ",")))] (printf "syms: %s\n" syms))
nil"syms: clojure.lang.LazySeq@9a965e88\n"(let [{{:keys [first], :as person} :name} {:first "john", :age 21}] [first person])
[nil nil]
(let [x (apply concat (repeatedly #(lazy-seq (print "X") [1 2 3])))])
nil(let [coll (range 10)] (take (count coll) (partition 2 1 (cycle coll))))
((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9) (9 0))
(let [s (sorted-set 1 2 3 4 5)] (disj s (first s)))
#{2 3 4 5}
(let [x (atom nil)] (swap! x (fn [_] (+ 3 4))) @x)
7(let [s [["a"] ["b"] ["a" "b"]]] (map #(apply str %) s))
("a" "b" "ab")
(let [s [["a"] ["b"] ["a" "b"]]] (mapcat #(apply str %&) s))
(\[ \" \a \" \] \[ \" \b \" \] \[ \" \a \" \space \" \b \" \])
(let [f (fn [x] x)] (= f (vary-meta f assoc :b 1)))
false(let [plus (fn [a b] (+ a b))] (reductions + (range 5)))
(0 1 3 6 10)
((fn [& keyword-args] (let [argmap (apply hash-map keyword-args)] (:key argmap))) :key 'here)
here(let [a '(1 2 3)] `(1 2 3 ~a ~@a))
(1 2 3 (1 2 3) 1 2 3)
(let [x (atom [1 2])] (swap! x (fn [[a b]] [b a])))
[2 1]
(let [filter-first (fn [at s] (let [[a b] (split-with #(not (= at %)) s)] (concat a (next b))))] (filter-first 1 '(9 6 1 3 1)))
(9 6 3 1)
(let [main [[2 3]] to-prepend [1] to-append [3]] (concat [to-prepend] main [to-append]))
([1] [2 3] [3])

