(do (use 'clojure.set) (let [a (ancestors (type 'wheeee)) b (ancestors (type :wheeee))] [(clojure.set/difference a b) (clojure.set/intersection a b)]))
[#{clojure.lang.AFn clojure.lang.IMeta clojure.lang.IObj} #{clojure.lang.IFn clojure.lang.IHashEq clojure.lang.Named java.io.Serializable java.lang.Comparable java.lang.Object java.lang.Runnable java.util.concurrent.Callable}]
(let [f (fn [a b c & more] (+ a b c (first more)))] (apply f (range 10)))
6(let [a (atom [])] (clojure.walk/prewalk #(do (swap! a conj %) %) '(+ a (- b c))) @a)
[(+ a (- b c)) + a (- b c) - b c]
(let [[foo bar] (split-with (comp not #{:b}) [:a :b :m :n :b :x])] (concat foo (rest bar)))
(:a :m :n :b :x)
(let [replacements [["a" "A"] ["b" "B"]]] (reduce (fn [str [from to]] (.replaceAll str from to)) "at bat" replacements))
"At BAt"(let [ns [3 3M 3.0 3.0M]] (for [a ns b ns :when (not (== a b))] [a b]))
()(let [vecvec [["a" "A" "b" "B"] ["z" "Z" "y" "Y"]]] (apply hash-map (map #(apply hash-map %) vecvec)))
{{"a" "A", "b" "B"} {"y" "Y", "z" "Z"}}
(let [{:keys [layer octave duration n-notes repetitions]} {:layer "0", :octave "5", :duration "q", :n-notes "16", :repetitions "2"}] [layer])
["0"]
(let [m {:a 1, :b 2, :c 3}] (zipmap (keys m) (map #(* 5 %) (vals m))))
{:a 5, :b 10, :c 15}
(reduce (fn [acc n] (let [v (+ acc n)] (if (= n 8) (reduced v) v))) 0 (range))
36(let [{:keys [flower1 flower2]} {:flower1 "red", :flower2 "blue"}] (str "The flowers are " flower1 " and " flower2))
"The flowers are red and blue"(let [i "I" worship "worship" his "his" shadow "shadow"] (str i \space worship \space his \space shadow \space))
"I worship his shadow "(let [fun (fn [] "foo") isfun (fn [x] (and (not (map? x)) (ifn? x)))] (prn (isfun fun)) (prn (isfun {})))
nil"true\nfalse\n"(let [a ('{a 1, b 2} 'a) b ('{a 1, b 2} 'b)] (+ a b))
3(let [[a b] (split-with #(not= 3 %) [1 2 3 4 5 6])] (concat a (rest b)))
(1 2 4 5 6)
(defmacro new-time [expr] `(let [start# (System/nanoTime) ret# ~expr] [(/ (double (- (. System (nanoTime)) start#)) 1000000.0) ret]))
#'user/new-time
(let [bs [0 1]] (for [a bs b bs c bs d bs] (str a b c d)))
("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")
(let [xs [[1 2] [3 5] [4 6] [7 9]]] (for [[a b] xs :when (odd? a)] b))
(2 5 9)
(take 10 (let [p (promise) s (lazy-cat [0 1] @p)] (deliver p (map + s (rest s))) s))
(0 1 1 2 3 5 8 13 21 34)
(let [indices [1 6 2]] (reduce #(assoc %1 %2 true) (vec (repeat (apply max indices) false)) indices))
[false true true false false false true]
(let [[x y & more] (list 1 2 3 4 5 6)] {:x x, :y y, :more more})
{:more (3 4 5 6), :x 1, :y 2}
(let [a 2 b 1 [a b] (if (< a b) [a b] [b a])] (println a b))
nil"1 2\n"(let [[x & xs] (range 5) [y z & lala] xs yz [y z]] (print x yz lala))
nil"0 [1 2] (3 4)"(let [s-a-x (fn [& args] (apply (comp #(map (partial + 1) %) range) args))] (s-a-x 1 3))
(2 3)
(let [[first-row second-row third-row] (iterate (partial drop 3) [1 2 3 4 5 6 7 8 9])] third-row)
(7 8 9)
(let [f (partial (fn [a b] (str a " " b)) "fixed")] (println (f "one")) (println (f "two")))
nil"fixed one\nfixed two\n"(let [a (sorted-map :a 1 :b 2 :c 3) k (keys a)] (take-while #(not= % :c) k))
(:a :b)
(let [foo (fn [x y z] (+ 1 x y z)) bar (partial foo 0)] (bar 6 9))
16(let [keys ["a" "b"] val-vecs [[1 2] [3 4]]] (map #(into {} (map vector keys %)) val-vecs))
({"a" 1, "b" 2} {"a" 3, "b" 4})
(let [s [1 5 4 3 2 6 7]] ((comp (partial apply map max) (juxt identity rest)) s))
(5 5 4 3 6 7)
(let [m {:a nil, :b "foo", :c "bar", :d nil}] (zipmap (keys m) (replace {nil ""} (vals m))))
{:a "", :b "foo", :c "bar", :d ""}
(let [matrix [[1 2 3] [8 9 4] [7 6 5]]] (doseq [row matrix el row] (print el)))
nil"123894765"(let [{:keys [a], :strs [b], :syms [c]} {:a 1, "b" 2, 'c 3}] [a b c])
[1 2 3]
(let [v (vec (range 10)) n 3] (concat (subvec v 0 n) (subvec v (inc n) (count v))))
(0 1 2 4 5 6 7 8 9)
(let [v1 ["a" "b" "c"] v2 (vec (repeat 3 0))] (interleave v1 (map #(+ % 10) v2)))
("a" 10 "b" 10 "c" 10)
(let [points [[1 1] [2 2] [3 5]]] [(reduce + (map first points)) (reduce + (map second points))])
[6 8]
(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq :when (> x y)] x))
(2 2 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 14 14 14 14 14 14 14 14 14 14 14 14 17 17 17 17 17 17 17 17 17 17 17 17 17 17 13 13 13 13 13 13 13 13 13 13 13 2 2 5 5 5 5 5 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 8 8 8 8 8 8 8 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 2...
(let [[match? month day year] (re-matches #"(\d+)-(\d+)-(\d+)" "08-14-2009")] [match? month day year])
["08-14-2009" "08" "14" "2009"]
(let [r 1 g 90 b 180] (-> r (bit-or (bit-shift-left g 8)) (bit-or (bit-shift-left b 16))))
11819521(let [items '(a b c)] (reduce (fn [[i acc] x] [(inc i) (conj acc x)]) [0 []] items))
[3 [a b c]]
(let [+i (fn [n] (inc (or n 0)))] (reduce #(update-in % [%2] +i) {} (seq "foo bar baz")))
{\space 2, \a 2, \b 2, \f 1, \o 2, \r 1, \z 1}
(let [fn-call #(apply % %&)] (some fn-call [(fn []) (fn []) #(- 5 1) #(+ 1 2)]))
4(let [matrix [[1 2 3] [4 5 6] [7 8 9]]] (doseq [row matrix el row] (print el)))
nil"123456789"(let [[a b c :as d :as e] [1 2 3 4 [5 6]]] [a b c d])
[1 2 3 [1 2 3 4 [5 6]]]
(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq :while (> x y)] x))
(8 28 28 21 21 24 24 29 29 29 29 29 24 24 20 20 21 21 25 25 4 27 27 6 26 26 26 26 28 28 11 11 28 28 29 29 29 29 29 20 20 19 19 24 24 9 9 11 11 16 16 9 9 16 16 25 25 5 23 23)
(let [i (atom 0)] {:filter (first (filter #(do (swap! i inc) (odd? %)) (range 25))), :i i})
{:filter 1, :i #object [clojure.lang.Atom 0x710d8e8f {:status :ready, :val 25}]}
(conj (vec (drop-last [1 2 3 4])) (let [l (last [1 2 3 4])] (* l l l)))
[1 2 3 64]
(let [items '[a b c]] (for [x items y items :while (not= x y)] #{x y}))
(#{a b} #{a c} #{b c})
(let [a [1 2 3] _ (prn a) b (map inc a) _ (prn b)] 'foo)
foo"[1 2 3]\n(2 3 4)\n"(let [s [1 3 5 6 7 8 10]] (concat (take-while odd? s) (take 1 (drop-while odd? s))))
(1 3 5 6)

