(let [idx (partition 3 (range 9))] (concat idx (apply map list idx) [[0 4 8] [2 4 6]]))
((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) [0 4 8] [2 4 6])
(let [a [1 2 3] z (map long a) [_ ^long b] z] (= b 2))
true(let [x [:a :b :c :d :e]] (map vector x (cons [] (reverse (take (count x) (iterate pop x))))))
([:a []] [:b [:a]] [:c [:a :b]] [:d [:a :b :c]] [:e [:a :b :c :d]])
(let [state (atom {:plots [[1 2] [1 5]]})] (do (swap! state update-in [:plots 2] (constantly [3 4])) @state))
{:plots [[1 2] [1 5] [3 4]]}
((fn transpose [m] (let [s (count m)] (partition s (apply interleave m)))) [[1 2 3] [:a :b :c]])
((1 :a) (2 :b) (3 :c))
(let [{[x & y] :items} {:hp 100, :mana 10, :items '[sword bread apple hammer]}] [x y y])
[sword (bread apple hammer) (bread apple hammer)]
(let [better-age-atom (atom {:agec 0, :ages 0})] (defn age-avg [] (let [{:keys [agec ages]} @better-age-atom] (/ ages agec))) (defn age+ [age] (if (and (< 0 age) (> 120 age)) (swap! better-age-atom #(-> %1 (update-in [:agec] inc) (update-in [:ages] + age))))))
#'user/age+
(let [last-nth (fn [coll n] (nth coll (- (count coll) n 1)))] (= (last-nth [1 2 3] 2) 1))
true(let [m1 {:a 1, :b 2} m2 {:b 2, :c 3}] (->> (keys m1) (remove #(contains? m2 %))))
(:a)
(let [a (atom 0) action (delay (swap! a inc)) f #(force action)] [(f) (f) (f)])
[1 1 1]
(let [v (vec (range 10)) positions #{1 4 8}] (reduce #(assoc %1 %2 :new-value) v positions))
[0 :new-value 2 3 :new-value 5 6 7 :new-value 9]
(let [x 5] (condp > x 1 "> 1 x" 5 "> x 5" 6 "x > 6" "other"))
"x > 6"(let [my-list (fn [name] (printf "Making %s list\n" name) (list 1 name))] (take 1 (concat (my-list "red") (my-list "blue"))))
(1)
"Making red list\nMaking blue list\n"(let [{out1 :x, out2 :xx} {:x {:y 1, :z 2}, :xx {:yy 3, :zz 4}} full-output [out1 out2]] full-output)
[{:y 1, :z 2} {:yy 3, :zz 4}]
(let [struct-foo {:a 1, :b 2, :x 3, :y 4} struct-bar {:x 5, :y 6}] (select-keys struct-foo (keys struct-bar)))
{:x 3, :y 4}
(doseq [x '({:user "a", :reps {:a 1, :b 2}})] (let [{a :user, rs :reps} x] (print (keys rs))))
nil"(:a :b)"(let [m {"e" 5, "b" 2, "a" 1} sm (into (sorted-map-by #(< (m %1) (m %2))) m)] sm)
{"a" 1, "b" 2, "e" 5}
(let [x 1 x x x x x x x x x x x x x x] (println x))
nil"1\n"(let [f (memoize (fn foo [x] (prn x) (if (pos? x) (foo (dec x)) x)))] (f 5) (f 6))
0"5\n4\n3\n2\n1\n0\n6\n5\n4\n3\n2\n1\n0\n"((fn [& all] (let [xall (butlast all) last (last all)] (map #(%) xall) last)) (println 1) 2 3)
3"1\n"(let [a (sorted-map :a 1 :b 2 :c 3) k (keys a)] (last (take-while #(not= % :c) k)))
:b(let [{:keys [a], :syms [b], :strs [c], :as foo} {:a 1, 'b 2, "c" 3}] [a b c foo])
[1 2 3 {:a 1, b 2, "c" 3}]
(let [printables (map char (range 33 127)) random-printables (fn [] (repeatedly #(rand-nth printables)))] [(take 10 (random-printables)) (take 10 (random-printables))])
[(\F \M \; \y \| \. \# \d \B \X) (\o \4 \: \3 \z \{ \X \? \{ \Z)]
(let [f #(* % %)] (map #(take %1 (iterate f %2)) (iterate inc 1) (range 10 14)))
((10) (11 121) (12 144 20736) (13 169 28561 815730721))
(let [f #(fn [& y] (apply % (reverse y)))] ((f map) (replicate 10 (range 10)) (partial map inc)))
((1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10))
(let [invoker (fn ([a] (. Integer valueOf a)) ([a b] (. Integer valueOf a b)))] (apply invoker ["100" 2]))
4(let [num 20 div -6 [a b] ((juxt quot rem) num div)] (= (+ (* a div) b) num))
true(let [[a b] (split-with #(>= 50 %) [10 20 30 35 40 50 60])] (concat [(last a)] b))
(50 60)
(let [s-a-x (fn [& args] ((partial apply (comp #(map (partial + 1) %) range)) args))] (s-a-x 1 3))
(2 3)
(let [y "\ufeffPersonnelNbr" x (clojure.string/replace y #"\p{Cf}|\p{Cc}" "")] (= (read-string (pr-str x)) (read-string (pr-str y))))
false((fn [& args] (let [{:keys [a b], :or {a 1, b 2}} (apply hash-map args)] [a b])) :a 5)
[5 2]
(let [range-incl (fn [a b] (apply range (map + ((juxt min max) a b) [0 1])))] (range-incl 11 -3))
(-3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11)
(let [compose-n-times (fn [f n] (fn [x] (nth (iterate f x) n))) plus-10 (compose-n-times inc 10)] (plus-10 5))
15(let [f #(compare (:x %1) (:x %2))] (= {{:x 1, :name "juan"} 1} (sorted-map-by f {:x 1} 1)))
true(let [{:keys [parents], {:keys [mother father]} :parents} {:first "John", :last "Doe", :parents {:mother "Alicia", :father "George"}}] [parents mother father])
[{:father "George", :mother "Alicia"} "Alicia" "George"]
((fn [s] (let [sep #"," foo (clojure.string/split s sep)] (if (= (str (last s)) (str sep)) true false))) "a,b,c,d")
false(defn foo [#^"[[J" x] (loop [a (long 0)] (recur (aget (let [#^longs y (aget x 1)] y) 1))))
#'user/foo
(let [hour-a 23 hour-b 6] (rem (- (+ (if (< hour-a (+ 12 hour-b)) 0 24) hour-b) hour-a) 24))
7(let [items '(a b c)] (reduce (fn [[i acc] x] [(inc i) (conj acc [x i])]) [0 []] items))
[3 [[a 0] [b 1] [c 2]]]
(let [b 15] (unchecked-byte (bit-shift-right (unchecked-multiply-int (bit-or (bit-and (unchecked-multiply-int b 0x0802) 0x22110) (bit-and (unchecked-multiply-int b 0x8020) 0x88440)) 0x10101) 16)))
-16(defn ab [] (let [a (atom 0)] (fn [x] (if (= x :inc) (swap! a inc) (swap! a dec)) @a)))
#'user/ab
(let [a (lazy-seq (cons (do (println "one") 1) (lazy-seq (cons (do (println "two") 2) nil))))] (first a) (first a))
1"one\n"(defn keys-and-vals [m] (let [pairs (seq m) ks (map first pairs) vals (map second pairs)] [ks vals]))
#'user/keys-and-vals
(defn clamp [min-x max-x x] (let [min-x (or min-x x) max-x (or max-x x)] (min (max min-x x) max-x)))
#'user/clamp
(let [board [[nil nil nil] [nil nil nil] [nil nil nil]] move [1 1]] (update-in board move (constantly 'x)))
[[nil nil nil] [nil x nil] [nil nil nil]]
(defn real-varargs [f required-count] (fn [& args] (let [[before after] (split-at required-count args)] (apply f (concat before [(into-array after)])))))
#'user/real-varargs
(let [hour-a 23 hour-b 20] (mod (- (+ (if (< hour-a (+ 12 hour-b)) 0 24) hour-b) hour-a) 24))
21((fn [s] (let [sep #"," foo (clojure.string/split s sep)] (if (= (str (last s)) (str sep)) true false))) "a,b,c,d,")
true(let [in (range 1 20)] (map first (take-while #(< (second %) 9) (map list in (reductions + in)))))
(1 2 3)
(let [x 5 y 2] (str "The average of " x " and " y " is " (/ (+ x y) 1)))
"The average of 5 and 2 is 7"

