(def make-id (let [a (atom 0)] (fn [] (swap! a inc))))
#'user/make-id
(let [a (promise)] (deliver a 20) (deliver a 10) @a)
20(let [required [:foo :bar] x {:foo 1}] (every? x required))
false(let [s "long string"] (subs s (- (count s) 3)))
"ing"(let [s (apply sorted-set (range 10))] (subseq s >= 5))
(5 6 7 8 9)
(let [x '(print :changed)] `(not-print ~@(next x)))
(user/not-print :changed)
(macroexpand '(let [foo ^{f ?, w t} []] foo))
(let [foo []] foo)
(let [y +] (defn x [a b] (y a b)))
#'user/x
(let [n 3 a [1 2] b [11 22 33 44 55]] (take n (let [ca (count a)] (concat a (drop ca b)))))
(1 2 33)
(let [a {:a 1, :b 0, :c 1}] (let [m (reduce max (vals a))] (for [[k v] a :when (= v m)] k)))
(:a :c)
(let [test-kwargs (fn [x y & args] (let [kwargs (apply hash-map args)] (println x y kwargs)))] (test-kwargs "one" "two" :foo true :bar false :baz []))
nil"one two {:baz [], :bar false, :foo true}\n"(let [g (->> (gensym) str (re-find #"\d+") (#(Integer/parseInt %)) inc inc inc (str "G__") symbol)] ((juxt identity eval) `(let [~g (gensym)] ~g)))
[(clojure.core/let [G__1218876 (clojure.core/gensym)] G__1218876) G__1218876]
(let [chores [1 2 3]] (conj (subvec chores 1) (first chores)))
[2 3 1]
(let [a (atom 1)] (= [0 a 0] [0 a 0]))
true(let [a 3 f (fn [%] (+ a %))] (f 5))
8(defn count [n] (let [counter (atom n)] #(swap! counter inc)))
#'user/count
(let [f (juxt first last)] (f [6 7 8 9 10]))
[6 10]
(let [v [5 4 3 2 1 0]] (mapv v v))
[0 1 2 3 4 5]
(let [s "asdf"] (if (re-matches #"a" s) '(:yes) '(:no)))
(:no)
(let [str "Wokka wokka!"] (= \! (.charAt str (dec (count str)))))
true(let [elts (vec (range 100))] (take 10 (repeatedly #(rand-nth elts))))
(15 1 41 13 73 2 40 58 23 25)
(let [a (atom {:a 1})] (swap! a assoc :b 2) @a)
{:a 1, :b 2}
(let [t {:a {:b {:c 1}}}] (-> t :a :b :c))
1(let [t (map transient (repeat 2 []))] (= (first t) (second t)))
false((fn [aseq] (let [foo (nth aseq 1000000)] foo)) (iterate inc 1))
1000001(let [v [7 9]] (disj (into #{} (range 1 12)) v))
#{1 2 3 4 5 6 7 8 9 10 11}
(let [middle [4 5 6]] `[10 11 ~@middle 12 13])
[10 11 4 5 6 12 13]
(let [coll [200 200]] (identical? (nth coll 0) (nth coll 1)))
false(let [s #{1 2 4 8}] (filter s (range 10)))
(1 2 4 8)
(let [m {0 :a, 1 :b}] (zipmap (vals m) (keys m)))
{:a 0, :b 1}
(let [t (transient [1 2 3])] (get t (dec (count t))))
3(let [[f & r] [1 2 3]] (every? #{f} r))
false(let [[a b & [c]] [1 2]] (list a b c))
(1 2 nil)
(let [{t1 :x, t2 :y} {:x "hello", :y "goodbye"}] [t1 t2])
["hello" "goodbye"]
(binding [*print-meta* true] (let [foo ^{:type :bla} 'x] (pr-str foo)))
"x"(let [[a b] (repeat 10 :foo) #(println "boom!")] [a b])
[:foo :foo]
(let [[function & args] (list / 1 3)] (apply function args))
1/3(let [{:keys [x y]} {:rs/x 1, :rx/y 2}] (prn x y))
nil"nil nil\n"(let [f (comp (partial + 1) (partial * 3))] (f 10))
31(map #(let [a %] into {} [[1 2]]) [:a :b :c])
([[1 2]] [[1 2]] [[1 2]])
(let [[_ a _ b] [1 2 3 4]] [a b])
[2 4]
(defmacro my-let [vecx & body] `(let ~(eval vecx) ~@body))
#'user/my-let
(let [c [{:foo 1} {:foo 3, :mykey 7}]] (filter :mykey c))
({:foo 3, :mykey 7})
(for [a (rest (range 5))] (let [r [a a a]] r))
([1 1 1] [2 2 2] [3 3 3] [4 4 4])
(let [{:strs [a b]} {"a" 1, "b" 2}] (list a b))
(1 2)
(let [form '(a b c)] `(insert stuff like ~@form))
(user/insert user/stuff user/like a b c)
(defmacro let-threaded [val varname & body] `(let [~varname ~val] ~@body))
#'user/let-threaded
(let [[a b c d e f g h] (range)] h)
7(macroexpand-1 '(let [{:as m, a :a} 5] (println a m)))
(let [{a :a, :as m} 5] (println a m))
(defn foo [s] (let [re #"\d+"] (when (re-seq re s) true)))
#'user/foo

