(let [boolean? (comp (partial apply =) (juxt identity boolean))] (map boolean? [1 true false]))
(false true true)
(let [f (partial max-key identity)] (f 1 2 3) (f 4 2) (f 5))
5(let [ap (partial partial apply)] (map (ap +) [[1 2 3] [4 5 6]]))
(6 15)
(defn filter-first [pred col] (let [[x y] (split-with pred col)] (concat x (rest y))))
#'user/filter-first
(let [x nil y nil coll [1]] (filter #(#{x y} %) coll))
()(let [fs (for [n (range 3)] #(* n n))] (for [f fs] (f)))
(0 1 4)
(let [delim "^"] (clojure.string/split "hello^world" (re-pattern (->> delim first int (format "%04x") (str "\\u")))))
["hello" "world"]
(defn remove-nth [coll n] (let [[f r] (split-at n coll)] (concat f (rest r))))
#'user/remove-nth
(let [a 23 b 20] (rem (min (- a b) (- b a)) 24))
-3(let [a (fn [& {:keys [a b]}] [a b])] (a {:a 1, :b 2}))
[1 2]
(let [a [1 2 3] b [4 5 6]] (mapv + a b))
[5 7 9]
(let [x [0 1 2 3]] (for [i (range (count x))] (drop i x)))
((0 1 2 3) (1 2 3) (2 3) (3))
(let [a (atom {:x {:y {:z 1}}})] (swap! a update-in [:x :y :z] inc))
{:x {:y {:z 2}}}
(let [foo [1 2 3]] [(nth foo 0) (nth foo 1) (nth foo 2)])
[1 2 3]
(let [m {:a 1, :b 2, :c 3} k [:a :b]] (select-keys m k))
{:a 1, :b 2}
(let [a {:b [:c :d]}] (doseq [[x [y z]] a] (println x y z)))
nil":b :c :d\n"(let [coll [1 2 3 [10 20] 4]] (mapcat #(vector % %) coll))
(1 1 2 2 3 3 [10 20] [10 20] 4 4)
(let [coll [3 11 8 5 100 13]] (map + coll (concat [0] coll)))
(3 14 19 13 105 113)
(let [[k & ks :as keys] (range 5)] {:k k, :ks ks, :keys keys})
{:k 0, :keys (0 1 2 3 4), :ks (1 2 3 4)}
(let [ev (fn [[f & args]] (apply f args))] (ev (list + 2 3)))
5(let [body '(a b)] `(do ~@(for [b body] `(print ~b))))
(do (clojure.core/print a) (clojure.core/print b))
(let [a1 (gensym "a") a2 (symbol (str "a" "11687"))] [a1 a2 (= a1 a2)])
[a3405427 a11687 false]
(let [f (fn [coll] (into (empty coll) [[1 2] [3 4]]))] (f {1 2}))
{1 2, 3 4}
(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] x))
(20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 ...
(let [roll (fn [] (repeatedly 5 #(rand-int 100)))] (map (partial vector (roll)) (range 10)))
([(49 40 94 26 9) 0] [(49 40 94 26 9) 1] [(49 40 94 26 9) 2] [(49 40 94 26 9) 3] [(49 40 94 26 9) 4] [(49 40 94 26 9) 5] [(49 40 94 26 9) 6] [(49 40 94 26 9) 7] [(49 40 94 26 9) 8] [(49 40 94 26 9) 9])
(let [x [1 2 3 4 0]] (take-while true? (map < x (rest x))))
(true true true)
(let [value false m {:first "thing"}] (or (and value (assoc m :test value)) m))
{:first "thing"}
(let [nested-map {:foo {:bar 12}} func (fn [{{bar :bar} :foo}] bar)] (func nested-map))
12(let [a {:x 1} b (assoc a :y 10)] (println a) (println b))
nil"{:x 1}\n{:x 1, :y 10}\n"(map #(let [n (int %)] (if (= n %) n %)) [9.0 4.25])
(9.0 4.25)
(let [a {} b (assoc a :foo 42) c (assoc b :bar "OK")] [a c])
[{} {:bar "OK", :foo 42}]
(let [n [:a :b :c] r [22 33]] (butlast (interleave n (conj r nil))))
(:a 22 :b 33 :c)
(let [a 1 b (println a) c (println "also") d 2] d)
2"1\nalso\n"(let [{{:keys [company-id user-id]} :params, :as request} {:params {:company-id 1, :user-id 2}}] [company-id user-id])
[1 2]
(let [a 10] [[a 1] '(a 1) (list a 1) `(a 1)])
[[10 1] (a 1) (10 1) (user/a 1)]
(defmacro with-turbo [turbo-on & body] `(let [~'map ~(if turbo-on `clojure.core/pmap `clojure.core/map)] ~@body))
#'user/with-turbo
(let [[x y] [1 2 3]] (println "x: " x ", y: " y))
nil"x: 1 , y: 2\n"(let [m {:a 3, :b 2}] (for [[k n] m _ (range n)] k))
(:a :a :a :b :b)
(let [x (fn [{y :k} {z y}] z)] (println (x {:k :v} {:v :s})))
nil":s\n"(let [m {:a (into-array [1])}] (aset (:a m) 0 99) (-> m :a first))
99(let [stuff {:a 0, :b 1, :params "ok"} {params :params, :as req} stuff] params)
"ok"(let [v (vec (range 20))] (into (subvec v 0 10) (subvec v 14 19)))
[0 1 2 3 4 5 6 7 8 9 14 15 16 17 18]
(let [struct [["a" "1"] ["b" "2"] ["c" "3"]]] (partition (count struct) (apply interleave struct)))
(("a" "b" "c") ("1" "2" "3"))
(let [value 2] (if (> value 2) "foo" (if (< value 2) "bar" "baz")))
"baz"(let [{{a :a, b :b} :numbers} {:numbers {:a 1, :b 1}}] (+ a b))
2(let [fn-name 'tompkins] `(do (defmulti ~fn-name [a b c] (+ 1 2 3))))
(do (clojure.core/defmulti tompkins [user/a user/b user/c] (clojure.core/+ 1 2 3)))
(let [x '[a b c d e]] (->> x count rand-int (nth x)))
c(do (use 'clojure.set) (let [t (atom #{:a :b})] (swap! t difference @t) @t))
#{}
(count "(let [[n l r & st] '(:a :b nil)] st)")
36(let [hello (fn [{name :name, :or {name "unknown person"}}] (println "hello, " name))] (hello {}))
nil"hello, unknown person\n"

