(let [n 5] (dotimes [n (+ 1 n)] (print n)))
nil"012345"(let [s (java.io.StringWriter.)] (binding [*out* s] (println "foo") (str s)))
"foo\n"(let [m {:thunk #(.substring "foo" 1 3)}] ((:thunk m)))
"oo"(macroexpand-1 '(let [{:keys [b a], :or {b a}} m]))
(let [{:keys [b a], :or {b a}} m])
(let [x (range 5)] (if (rest x) x (first x)))
(0 1 2 3 4)
(let [digits (fn [n] (map int (str n)))] (digits 123))
(49 50 51)
(let [x [1 2 3]] [x (conj x 4) x])
[[1 2 3] [1 2 3 4] [1 2 3]]
(let [x (first {:a 2})] (identical? x (first (into {} [x]))))
false(let [[f & r] #{2 3 4}] [f r])
[4 (3 2)]
(let [[x y] '((1 2) (3 4))] [x y])
[(1 2) (3 4)]
(let [f (fn [] #{"one" "two" "three"})] (identical? (f) (f)))
true(let [m {:foo 3}] (println (get m (first (keys m)))))
nil"3\n"(let [k (keyword "Stupid Key") test {k 10}] (k test))
10(binding [*read-eval* true] (read-string "#=(let [x 1] x)"))
1(defmacro let-map [& pairs] (let [names (map first (partition 2 pairs))] `(let [~@pairs] (zipmap [~@(map (comp keyword name) names)] [~@names]))))
#'user/let-map
(let [m {:foo 4}] (identical? m (assoc m :foo 4)))
true(let [wrapper #(apply identity %&)] (wrapper [1 2 3]))
[1 2 3]
(let [named-first (with-meta first '{:name first})] (:name (meta named-first)))
first(let [a (promise)] (deliver a 10) (deliver a 20) @a)
10(let [{some-a :a, some-b :b} {:a 0, :b 1}] some-b)
1(let [args '[some args]] `(defn any [map ~@args]))
(clojure.core/defn user/any [clojure.core/map some args])
(let [[x y :as args] [1 2 3 4]] args)
[1 2 3 4]
(let [[x] (doto (re-matcher #"(foo)" "foo") re-find)] x)
"foo"(let [p [1 2 3]] (map list p (rest p)))
((1 2) (2 3))
(let [[a b :as all] [1 2]] [a b all])
[1 2 [1 2]]
(let [[n [d]] '(a (b))] {:n n, :d d})
{:d b, :n a}
(let [foo (fn [^Integer x] (+ 3 x))] (foo 5.0))
8.0(let [ys (range 10) xs (lazy-seq (filter even? ys))] xs)
(0 2 4 6 8)
(let [{:keys [a b]} {:a 1, :b 2}] [a b])
[1 2]
(let [f (partial + 1)] (take 5 (iterate f 5)))
(5 6 7 8 9)
(let [bytes (.getBytes "byte me")] (bit-and (aget bytes 0) 0xFF))
98(let [m {:a 1}] (update-in m [:b] (fnil inc 0)))
{:a 1, :b 1}
(let [a (atom {1 {:ugh :yay}})] (-> 1 (@a) :ugh))
:yay(let [] (def a-b 20) (def a_b 30) (println a-b a_b))
nil"20 30\n"(let [spinner (iterate not true)] (list (fnext spinner) (fnext spinner)))
(false false)
(defmacro mm [a & body] (let [ea ~a] `(...)))
#'user/mm
(let [a {:one 1, :two 2}] (map a [:one :two]))
(1 2)
(let [{:keys [foo bar]} {:foo 1, :bar 2}] [foo bar])
[1 2]
(let [{:keys [a b]} [:a 1 :b 2]] [b a])
[nil nil]
(let [s (range 5)] (for [x s] (println x)) 'done)
done(let [xs (range 1000000) f (fn [] (last xs))] (f))
999999(let [s "hello, worldo"] (subs s 0 (dec (count s))))
"hello, world"(let [x [:a] y (conj x :b)] (println x y))
nil"[:a] [:a :b]\n"(let [char-to-nums :foo] (= '(0 char-to-nums) (list 0 char-to-nums)))
false(let [[a _ b] [1 2 3 4]] [a b])
[1 3]
(def times-two (let [x 2] (fn [y] (* y x))))
#'user/times-two
(let [s "k1=v1;k2=v2"] (apply hash-map (clojure.string/split s #"[=;]")))
{"k1" "v1", "k2" "v2"}
(let [[x y z :as vec] [1 2 3]] vec)
[1 2 3]
(let [a 1] (case (< a 2) true :yes :no))
:yes(let [[a & b] [1 2 3 4]] [a b])
[1 (2 3 4)]

