(let [lalala 1] (defn foo [a b c] (println a b c)))
#'user/foo
(let [hello (fn [{:keys [name]}] (println "hello, " name))] (hello {:name "constantine"}))
nil"hello, constantine\n"(let [c (atom 3)] (while (< 0 @c) (prn (swap! c dec))))
nil"2\n1\n0\n"(let [junk [:a :b]] (dissoc {:a 1, :b 2, :c 3} junk))
{:a 1, :b 2, :c 3}
(let [[function & args] (list '/ 1 3)] (apply (var function) args))
3(let [{a 1, b 2} #{1 2 3 4}] [a b])
[1 2]
(let [a 1 b (+ 2 a) c (* 4 b)] c)
12(let [x 5 inner `(foo bar ~x)] (list 'do x inner))
(do 5 (user/foo user/bar 5))
(let [x (atom {:foo 1, :bar 2})] (swap! x dissoc :foo) @x)
{:bar 2}
(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq] x))
(6 16 16 2 20 17 7 15 13 2 27 10 28 6 1 22 6 23 8 29 5 1 27 10 21 13 15 8 22 12)
(let [[head & rest] (list 1 2 3)] {:head head, :rest rest})
{:head 1, :rest (2 3)}
(defn true-times [n] (let [state (atom 0)] (> (swap! state inc) n)))
#'user/true-times
(let [filter-first (fn [pred s] (let [[a b] (split-with pred s)] (concat a (next b))))] (filter-first #(= 1 %) '(9 6 1 3 1)))
(6 1 3 1)
(let [[a & bs :as v] [1 2 3]] [a bs v])
[1 (2 3) [1 2 3]]
(let [a (transient {})] (dotimes [i 20] (assoc! a i i)) (persistent! a))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7}
(let [foo #(partial conj (empty %))] ((foo [1 2 3]) 4))
[4]
(defn sharky [& more] (let [{:as opts} (drop-last 2 more)] (opts more)))
#'user/sharky
(let [m {:a 1, :b {:x 42}}] (interleave (keys m) (vals m)))
(:a 1 :b {:x 42})
(let [e (gensym)] `(try ... (catch Exception ~e (. ~e ...))))
(try user/... (catch java.lang.Exception G__1204433 (. G__1204433 user/...)))
(let [v []] (do (for [item [1 2 3]] (conj v item)) v))
[](let [hm (hash-map "a" 1 "b" 2)] ((keyword (second (keys hm))) hm))
nil(let [xs '[a b c d]] (map list xs (rest xs)))
((a b) (b c) (c d))
(let [L (with-meta '(a b) {:foo :bar})] (meta (conj L 'c)))
{:foo :bar}
(let [[fname & args] (.split "plane flies-to paris" " ")] [fname args])
["plane" ("flies-to" "paris")]
((let [*foo* 2] (with-local-vars [*foo* 3] (do (print @*foo*) (fn [] (print @*foo*))))))
nil"3nil"(let [m {:a (delay (rand-int 1))}] [@(:a m) @(:a m)])
[0 0]
(let [x ^{:a 1, :b 2} [1 2 3]] (meta x))
{:a 1, :b 2}
(take 20 (let [☃ '(❅ ❆)] (cycle (concat '(☃) ☃))))
(☃ ❅ ❆ ☃ ❅ ❆ ☃ ❅ ❆ ☃ ❅ ❆ ☃ ❅ ❆ ☃ ❅ ❆ ☃ ❅)
(let [a 1 _ (prn a) a 2 _ (prn a)] a)
2"1\n2\n"(let [x [1 2 3]] [(concat x [4]) (concat x [5]) x])
[(1 2 3 4) (1 2 3 5) [1 2 3]]
(binding [*print-meta* true] (let [foo (with-meta {:not 'asymbol} {:type :bla})] (pr-str foo)))
"{:not asymbol}"(let [m (fn [x y] (max x y 3))] (m 4 5))
5(defmacro apply-not-nil [func expr] `(let [expr-result# ~expr] (when expr-result# (~func expr-result#))))
#'user/apply-not-nil
(let [x {:p {:p {:p nil}}}] (rest (take-while identity (iterate :p x))))
({:p {:p nil}} {:p nil})
(let [{a "ja", b "nein"} {:x 4, "ja" 8}] (println a b))
nil"8 nil\n"(defn pick-random [set] (let [sq (seq set)] (nth sq (rand-int (count sq)))))
#'user/pick-random
(#(let [& 1 % 2] %&) 3 4 5 6 7)
(4 5 6 7)
(let [x {Double/NaN 42}] (not= (= x x) (= x (into {} x))))
true(let [t (transient {})] (dotimes [n 40] (assoc! t n n)) (persistent! t))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7}
(let [in [1 2 3 [4 5]]] (into (pop in) (peek in)))
[1 2 3 4 5]
(let [a [1 2 3] [_ b] a] (= b 2))
true(let [x (next (cons 1 (lazy-seq (do (print "hi") '(5)))))] 'ok)
ok"hi"(let [m (with-meta {:a 1} {:type :some-map})] (type (assoc m :b 2)))
:some-map(let [a 1 b (+ a a) c (* b b)] c)
4(defn yielder [s] (let [a (atom s)] (fn [] (first (swap! a next)))))
#'user/yielder
(let [nums [1 2 3 4 5] [a b c] nums] c)
3(let [a {:name nil, :address nil} b (assoc a :name "cark")] b)
{:address nil, :name "cark"}
(let [{n :a, n2 :b} {:a 1, :b 2}] (+ n n2))
3(let [s " S I I ( S I I)"] (read-string s))
S(let [v #{1 2 3}] (into (empty v) (map inc) v))
#{2 3 4}

