(macroexpand '(let [{x :x, {x :x} :m} {:m {:x 2}, :x 1}] x))
(let [{x :x, {x :x} :m} {:x 1, :m {:x 2}}] x)
(defn or-comp [args & fns] (let [f (apply juxt fns)] (some true? (f args))))
#'user/or-comp
(let [[a b :as v] [1 2 3 4 5]] {:a a, :v v})
{:a 1, :v [1 2 3 4 5]}
(let [v [:a "b" :a "c"]] (zipmap (take-nth 2 v) (take-nth 2 (next v))))
{:a "c"}
(let [f (fn [val seq] (some #{val} seq))] (f :d [:a :b :c]))
nil(defn foo [n] (let [n (atom n)] (fn [i] (swap! n (partial + i)))))
#'user/foo
(let [{{:keys [x y]} :a} {:a {:x 0, :y 2}, :b 3}] [x y])
[0 2]
(let [f (fn [& {:keys [foo bar]}] foo)] (apply f (flatten (seq {:foo 1}))))
1(let [i (memoize deref) a (atom 1)] (i a) (reset! a 2) (i a))
1(let [x (iterate #(do (print "test") (inc %1)) 1)] (next x) (first x))
1(let [m (assoc {} :foo :bar)] (if (= 3 3) (assoc m :been "baz") m))
{:been "baz", :foo :bar}
(let [h {:a 1, :b 2, :c 3, :d 4}] [(keys h) (vals h)])
[(:a :b :c :d) (1 2 3 4)]
(let [v [1 2 3]] (= (take (count v) (iterate inc (first v))) v))
true(let [[[k k2] & nz] [[2 3] [0 6] [1 3]]] [k k2 nz])
[2 3 ([0 6] [1 3])]
(let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))
{:0 0, :1 1, :2 2, :3 3, :4 4, :5 5, :6 6, :7 7}
(let [required [:foo :bar] x {:foo 1}] (filter (fn [k] (not (x k))) required))
(:bar)
(let [v [:a :b]] (map (apply juxt v) [{:a 1, :b 2, :c 3}]))
([1 2])
(let [x 3 _ (println x) y (+ 1 2) _ (println y)] y)
3"3\n3\n"(let [[first second & rest :as s] [1 2 3]] [first second rest s])
[1 2 (3) [1 2 3]]
(let [[a :as [b :as [c & [d]]]] [1 2]] [a b c d])
[1 1 1 2]
(let [foo #(partial conj (empty %))] ((foo [1 2 3]) 4 5 6))
[4 5 6]
(let [{:strs [a b c]} {"a" 0, "b" 1, "c" 2}] [a b c])
[0 1 2]
(let [x [1 2 3 4]] (into (subvec x 0 1) (subvec x 2)))
[1 3 4]
(let [f #(println "f o" %) g #(str 'g)] ((comp f g)))
nil"f o g\n"(let [ks [1 2 3 4]] (zipmap ks (map #(* %1 %1) ks)))
{1 1, 2 4, 3 9, 4 16}
(let [m {:a 1, :b 2}] (into {} (zipmap (keys m) (map inc (vals m)))))
{:a 2, :b 3}
(defmacro dump-locals [] (let [syms (keys &env)] `(prn ~(zipmap (map keyword syms) syms))))
#'user/dump-locals
(let [v [1 2 3]] (concat (partition 2 1 v) [[(last v) (first v)]]))
((1 2) (2 3) [3 1])
(let [[[foo bar] {:keys [other thing]}] ["Hello" "World"] {:other "Good", :thing "bye"}] (println foo))
nil"H\n"(let [more '(1 2 3)] `(interpose " " ~(cons `list more)))
(clojure.core/interpose " " (clojure.core/list 1 2 3))
(let [m {1 2, 3 4}] (doseq [[k v] m] (println (+ k v))))
nil"3\n7\n"(defmacro defspecialblock [mname & body] `(let [{:keys ~'[your keys here]} ~mname] ~@body))
#'user/defspecialblock
(let [{foo :foo, bar :bar} {:foo 1, :bar 2}] (str foo ", " bar))
"1, 2"(let [result (transient {})] (doseq [elt (range 0 10)] (assoc! result elt elt)) (persistent! result))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7}
(let [a [1 2 3 4 5 7]] (map + a (cons 0 a)))
(1 3 5 7 9 12)
(let [lines [[3 2 3] [5 7 1]]] (map list lines (range (count lines))))
(([3 2 3] 0) ([5 7 1] 1))
(let [f (fn [] 1) y (with-meta f {:a 1})] (= (class f) (class y)))
false(let [my-maps [{:foo "bar", :biz "baz"} {:foo "sds", :biz "sdasdasd"}]] ((apply juxt my-maps) :foo))
["bar" "sds"]
(let [a (sort-by val {:a 1, :b 9, :d 0})] (pr a) (into {} a))
{:a 1, :b 9, :d 0}
"([:d 0] [:a 1] [:b 9])"(let [[x & {:keys [a b]}] [0 :a 1 :b 2]] [x a b])
[0 1 2]
(let [[a b] (int-array [1 2]) _ (println (str "a=" a " b=" b))])
nil"a=1 b=2\n"(let [villas ["a" "b" "c"]] (->> (interleave villas (-> villas count range)) (partition 2)))
(("a" 0) ("b" 1) ("c" 2))
(let [[x y & more] (seq {:foo 1, :bar 2, :baz 3})] (list y))
([:bar 2])
(do (defrecord trec [a b c]) (let [q (trec. 1 2 3)] (keys q)))
(:a :b :c)
(let [[x & xs] [nil nil nil nil]] (every? #(= x %) xs))
true(let [x [1 2] a (first x) b (rest x)] [a b])
[1 (2)]
(let [x (into-array [1 2 3 4])] (zipmap (take-nth 1 x) (take-nth 2 x)))
{1 1, 2 3}
(let [v1 [1 2 3] v2 (assoc v1 1 20)] (list v1 v2))
([1 2 3] [1 20 3])
(let [[x :as a & don't mind me] [0 1 2 3]] [x a])
[0 [0 1 2 3]]
(let [[a b] ((juxt + *) 2 3)] (str a " and " b))
"5 and 6"

