(let [[head & rest] '(1 2 3)] {:head head, :rest rest})
{:head 1, :rest (2 3)}
(defmacro foo [x] (let [fv (symbol "_" (str (gensym)))] `(~x ~fv)))
#'user/foo
(let [x (cons (do (print "test") 1) (cons 2 nil))] (first x))
1"test"(let [フォー "this code is not very readable to most people"] フォー)
"this code is not very readable to most people"(let [a (* 2 1) b (* 2 2)] (+ a b))
6(let [[fst [_ & rst]] (split-at 3 (range 10))] (concat fst rst))
(0 1 2 4 5 6 7 8 9)
(let [v (clojure.string/split "1,2,3,4" #",")] (map #(nth v %) [1 3]))
("2" "4")
(let [a [] b (conj a 1) onedex (dec (count b))] [b onedex])
[[1] 0]
(let [[f & r] [4 4 4 4]] (every? #{f} r))
true(defmacro foo [bar] `(let [~'a + ~'b 1 ~'c 2] ~bar))
#'user/foo
(let [s "hello there!"] (map (partial apply str) (split-with #{\space} s)))
("" "hello there!")
(let [myfn (fn [lst] (concat lst '(2)))] (myfn '(+ 1)))
(+ 1 2)
(let [a-rand-seq (repeatedly #(rand-int 10))] [(take 4 a-rand-seq) (take 7 a-rand-seq)])
[(3 6 7 4) (3 6 7 4 4 8 3)]
(let [v [:a :b :c]] (for [x v y v] [x y]))
([:a :a] [:a :b] [:a :c] [:b :a] [:b :b] [:b :c] [:c :a] [:c :b] [:c :c])
(let [m (fn [x y] (max x y 3))] (m 30 5))
30(let [[a b c d e] [1]] [a b c d e])
[1 nil nil nil nil]
(defmacro m [x] `(let [y# x] (if (odd? y#) :odd :even)))
#'user/m
(let [[:a :b & :rest] [1 2 3 4]] [a b rest])
[1 2 (3 4)]
(let [v [\a \b \c \d]] (assoc v 1 \space 4 \space))
[\a \space \c \d \space]
(let [row [123 "abc" 456] [x y z] row] [x z])
[123 456]
(let [a 10 b 20] (doall (doseq [num [a b]] (println num))))
nil"10\n20\n"(let [{:keys [a b]} {:a 2, :b 2, :c 3}] [b a])
[2 2]
(let [foo true] `(whatever whatever ~@(when foo [`(actual code)])))
(user/whatever user/whatever (user/actual user/code))
(let [x [1 2 3 4 0]] (map < x (rest x)))
(true true true false)
(let [plus (fn [a b] (+ a b))] (reductions plus (range 5)))
(0 1 3 6 10)
(let [m {:a 1, :b 2}] (assoc (dissoc m :a) :a 3))
{:a 3, :b 2}
(let [s1 (sorted-set "foo") s2 (sorted-set "bar" "foo")] (type (clojure.set/union s1 s2)))
clojure.lang.PersistentTreeSet(let [foo "bar" baz "quux"] (map (fn [k] [`'~k k]) [foo baz]))
([(quote "bar") "bar"] [(quote "quux") "quux"])
(defmacro essentially [& args] `(let ~(last args) ~@(butlast args)))
#'user/essentially
(let [l (list 1 2 3 4)] (for [element l] (str element)))
("1" "2" "3" "4")
(let [main [[2] [3]] to-prepend [1] to-append [3]] (concat [to-prepend] main [to-append]))
([1] [2] [3] [3])
(let [x '(1 2)] (identical? x (drop 1 (cons 0 x))))
false(macroexpand-1 '(let [{:or {k 50}, k :unknown, x :a} m] foo))
(let [{k :unknown, x :a, :or {k 50}} m] foo)
(let [{x :x, {x :x} :m} {:x 1, :m {:x 2}}] x)
2(let [{x 1, y 2} #{1 2 3 4}] [x y])
[1 2]
(let [a1 (atom :a) a2 (atom :a)] (assoc {a1 1} a2 1))
{#object [clojure.lang.Atom 0x733f3956 {:status :ready, :val :a}] 1, #object [clojure.lang.Atom 0x7df8d899 {:status :ready, :val :a}] 1}
(let [[a b] (re-matches #"a(b)c" "abc")] [:a a :b b])
[:a "abc" :b "b"]
(let [sr (java.io.StringReader. "hello, world!")] (apply str (repeatedly 5 #(.read sr))))
"104101108108111"(let [foo (subvec [1 2 3] 1 2)] (identical? foo (vec foo)))
true(let [[x & y] [1 2 3 4]] (println x) (println y))
nil"1\n(2 3 4)\n"(let [teams (range 1 9)] (take 4 (map list teams (reverse teams))))
((1 8) (2 7) (3 6) (4 5))
(defmacro aif [condition & body] `(let [~'it ~condition] (if ~'it ~@body)))
#'user/aif
(let [m {:foo 0, :bar 1}] (every? (partial contains? m) [:foo :bar]))
true(let [l '(a b c d)] (zipmap (range (count l)) l))
{0 a, 1 b, 2 c, 3 d}
(let [{a :value, b key, :or {a 10}} {:key "hello"}] [a b])
[10 nil]
(let [f0 "C:\\long\\fn.ext"] (second (re-find #"([^\\]*)\.[^.]*$" f0)))
"fn"(let [a {:a :b, :c :d}] (str (doall (map reverse (into [] a)))))
"clojure.lang.LazySeq@bc3043e0"(let [[a b] (repeatedly #(atom 0))] ((juxt = identical?) a b))
[false false]
(let [{negative true, others false} (group-by neg? (range -5 5))] [negative others])
[[-5 -4 -3 -2 -1] [0 1 2 3 4]]
(let [x '(vsubgraph blah)] (meta (second `(foo ~^List x))))
{:column 10, :line 1}

