(let [flat-keys (flatten [[:a :b] [:c :d]])] (zipmap flat-keys (repeat (count flat-keys) 0)))
{:a 0, :b 0, :c 0, :d 0}
(let [f {:blah :foo}] (= (with-meta f {:a 0}) (with-meta f {:a 1})))
true(let [x [1 2 3 4 5]] (into (empty x) (take 3 x)))
[1 2 3]
(let [[foo bar {:keys [other thing]}] ["hello" "world" {:other "good", :thing "bye"}]] foo)
"hello"((fn [aseq] (let [foo (nth aseq 1000000) bar 5] foo)) (iterate inc 1))
1000001(let [ "even number of forms, eh?" "let's make it even" "or not"] )
"or not"(let [lalala 1] (defn foo [a b c] (println a b c lalala)))
#'user/foo
(let [trailing-nl (. "foo" endsWith "o") x (if trailing-nl "yes" "no")] (println x))
nil"yes\n"(let [x (atom 0)] (dorun (take 10 (repeatedly #(swap! x inc)))) @x)
10(count (let [t (transient {})] (dotimes [i 100] (assoc! t i i)) (persistent! t)))
8(let [m (sorted-map :a 0 :b 1 :c 2)] (dissoc m (ffirst m)))
{:b 1, :c 2}
(let [v [1 2 3]] (interleave v (map #(+ 10 %) v)))
(1 11 2 12 3 13)
(let [pow (fn [a b] (reduce * (repeat b a)))] (pow 2/7 3))
8/343(let [x [1 2 3 4 5]] (nth x (-> x count rand-int)))
1(let [xs [[1 2] [3 4]]] (zipmap (map first xs) (map second xs)))
{1 2, 3 4}
(let [x (doall (map print [1 2 3 4 5 6 7]))] nil)
nil"1234567"(let [s (iterate inc 0)] (print (take 2 s)) (print (take 2 s)))
nil"(0 1)(0 1)"(let [x {:foo 5}] (for [i x] (str (key i) "=" (val i))))
(":foo=5")
(let [=== #(and (<= %1 %2) (<= %2 %1))] (=== 1 1.0))
true(let [x [1 2 3]] `(:a :b :c ~@x :d :e :f))
(:a :b :c 1 2 3 :d :e :f)
(let [!! (reduce * (range 2 7 2))] (* (- !! 6) !!))
2016(let [[_ _ _ d e] [1 2 3 4 5]] [d e])
[4 5]
(let [input [1 2 3 4]] (map #(remove #{%} input) input))
((2 3 4) (1 3 4) (1 2 4) (1 2 3))
(let [{:keys [a b], :or {a 1, b 2}} {:a 5}] [a b])
[5 2]
(let [[x y z] (rseq [:a :b :c :d :e])] [x y z])
[:e :d :c]
(let [vec [:a :b :c]] (some (comp #{:c} vec) (range (count vec))))
:c(defmacro mac [& a] `(loop [forms# '~a] (let [f# (first forms#)] f#)))
#'user/mac
(let [mystery [1 2 3 4]] (if (seq mystery) "It's seq'able!" "Not seq'able"))
"It's seq'able!"(let [$ (fn [& args] (apply comp (reverse args)))] (($ meta :doc) #'*read-eval*))
nil(do (defprotocol IFoo) (defrecord Foo [] IFoo) (let [foo (Foo.)] (assoc foo :foo 'foo)))
#user.Foo {:foo foo}
(let [[x & args] [100 78 7 9 12]] {:x x, :args args})
{:args (78 7 9 12), :x 100}
(defn true-times [n] (let [state (atom 0)] (fn [] (> (swap! state inc) n))))
#'user/true-times
(let [not-number #_(+ 1 2 (* 3 5)) "is a string"] not-number)
"is a string"(let [r (:repeat {} 0)] (if (< r 2) [r] (range 1 (inc r))))
[0]
(let [f (fn [] 1) y (with-meta f {:a 1})] [(class f) (class y)])
[sci.impl.fns$fun$arity_0__26683 clojure.lang.AFunction$1]
(let [x {:a 1, :b 2}] (zipmap (keys x) (map inc (vals x))))
{:a 2, :b 3}
(let [[a b c d] (seq (set (range 100000)))] [a b c d])
[0 60363 20083 25535]
(let [{name :name, {unit :unit} :quantity} {:name "foo", :quantity {:unit "meters"}}] [name unit])
["foo" "meters"]
(map-indexed #(assoc %2 :index %1) (let [b {} a {:s b}] [a b]))
({:index 0, :s {}} {:index 1})
(let [map-hash (comp (partial apply hash-map) mapcat)] (map-hash identity {:a 1, :b 2}))
{:a 1, :b 2}
(let [a (object-array 64) v (vec a)] (aset a 0 :hi) v)
[nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]
(defn make-operator [x y] (let [myx x] (fn [a b] (myx a b))))
#'user/make-operator
(let [ton #(apply + (map int %))] (> (ton "scheme") (ton "clojure")))
false(let [x [1 2 3 4]] (subvec x 0 3) (subvec x 3))
[4]
(let [me {:rollodex {:contacts {:mom "Anna", :dad :dead}}}] (-> me :rollodex :contacts :mom))
"Anna"(let [l 10 s (apply str "bB" (repeat l "a"))] s (for [i (range l)] (let [s (apply str (concat (take i s) (drop i s)))] [s (.hashCode s)])))
(["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616] ["bBaaaaaaaaaa" 626151616])
(let [chunker (partial partition-by (fn [x] (rand-int 3)))] (interleave (chunker "abcdefghijk") (chunker (range 10))))
((\a) (0) (\b) (1) (\c \d) (2 3) (\e \f) (4) (\g) (5) (\h \i \j) (6 7) (\k) (8))
(let [[a b] (re-matches #"(\d+) (\d+)" "12 34")] (prn a) (prn b))
nil"\"12 34\"\n\"12\"\n"(defn emit-bash-form [a] (let [c (class a)] (cond (= c java.lang.Integer) "int" :else nil)))
#'user/emit-bash-form
(let [a "c" b (str a \= a) c (str b \& b)] c)
"c=c&c=c"

