(let [my-nums [10 20 30 40] a (atom (cons nil my-nums)) read-num #(first (swap! a rest))] [(read-num) (read-num)])
[10 20]
(let [list [:foo :bar "baz" :quux :yay] [a [b & c]] (split-with (complement string?) list)] [a b c])
[(:foo :bar) "baz" (:quux :yay)]
(let [a '(1 2 3) b '(4 5 6)] (for [x a y b] (println x y)))
(nil nil nil nil nil nil nil nil nil)
"1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n"
(reduce (fn [b {:keys [a], :as m}] (assoc b a m)) {} [{:a 1, :b 2} {:a 2, :b 3}])
{1 {:a 1, :b 2}, 2 {:a 2, :b 3}}
((fn [a] (take a ((fn f [x] (lazy-cat x (map + (rest (f x)) (f x)))) [1 1]))) 10)
(1 1 2 3 5 8 13 21 34 55)
(let [[a [_ & b]] (split-with #(not= 3 %) [1 2 3 4 5 6])] (concat a b))
(1 2 4 5 6)
(defn link-nodes [& nodes] (deliver (:next (last nodes)) (first nodes)) (deliver (:prev (first nodes)) (last nodes)) (reduce (fn [a b] (deliver (:next a) b) (deliver (:prev b) a) b) nodes) nil)
#'user/link-nodes
((fn [x y & {:keys [a b c], :or {b 5}}] [x y a b c]) 1 2 :c 3)
[1 2 nil 5 3]
(let [a (fn b [x s] (if (pos? x) (b (dec x) (* x s)) s))] (a 5 1))
120
(let [[a b c] [1 2 3] v [a b]] (println "v is " v ", c is " c))
nil
"v is [1 2] , c is 3\n"
(let [{:keys [a b c]} {:a 1, :b 2, :c 3}] (str "My a is " a " and my b is " b " and my c is " c))
"My a is 1 and my b is 2 and my c is 3"
(let [[a [_ & b]] (split-with #(not= 3 %) [1 2 3 3 5 3 6])] (concat a b))
(1 2 3 5 3 6)
(let [a #{:a :b} b #{:c :a}] (clojure.set/difference (clojure.set/union a b) (clojure.set/intersection #{:a :b} #{:c :a})))
#{:b :c}
(let [{:keys [a b z], :or {z 10}, :as opts} {:a 1, :b 2, :c 3}] [a b z opts])
[1 2 10 {:a 1, :b 2, :c 3}]
(defn foo [x y & args] (reduce (fn [r [a b]] (assoc r (x a) (y b))) {} (partition 2 args)))
#'user/foo
(apply concat (-> (range 10) (((fn [f] (fn [a b] (f b a))) map) (fn [x] (if (even? x) [x] [])))))
(0 2 4 6 8)
(let* [iter__4470__auto__ (clojure.core/fn iter__2021 [s__2022] (clojure.core/lazy-seq (clojure.core/loop [s__2022 s__2022] (clojure.core/when-first [a s__2022] (clojure.core/cons a (iter__2021 (clojure.core/rest s__2022)))))))] (iter__4470__auto__ (range 5)))
(0 1 2 3 4)
(let [v [64 70 200 90]] (map (fn [a b] a) v (concat (take-while #(< % 200) v) [::extra])))
(64 70 200)
(defn toggler-factory [f1 f2] (let [a (atom true)] (fn [& args] (apply (if @a f1 f2) args) (swap! a not))))
#'user/toggler-factory
((fn [& {:keys [a b c d], :or {c 42, d 100}}] [a b c d]) :a 1 :b 2)
[1 2 42 100]
(defn swap!-old [a f & args] (let [old (atom nil)] (swap! a #(do (reset! old %) (apply f args)))))
#'user/swap!-old
(->> (range 20) (shuffle) (partition 3 1) (filter (fn [[a b c]] (and (< b a) (< b c)))) (first))
(10 2 11)
(let [[a b] (split-with (partial not= 3) [5 4 3 2 1 2 3 4 5])] (concat a (rest b)))
(5 4 2 1 2 3 4 5)
((fn merge-in [a b] (merge-with merge-in a b)) {:a {:b {:c {:d {}, :e :hi}}}, :f {}} {:a {:b {:c {:d {{} {}}}}}, :f {}})
{:a {:b {:c {:d {{} {}}, :e :hi}}}, :f {}}
(doseq [{a :a, b :b, :or {:a 1, :b 2}} #{{:a 3} {:b 4}}] (println a " " b))
nil
"3 nil\nnil 4\n"
(defmacro a [& b] `(let [b# ~b] b#))
#'user/a
(map #(ns-unmap *ns* %) '(temp-vars ummm a))
(nil nil nil)
(let [[a b] (for [x ["1" "2"]] (Integer/parseInt x))])
nil
(macroexpand '(-> (a b) (c d) (e f)))
(e (c (a b) d) f)
(map vector '[[a b c] [1 2 3]])
([[a b c]] [[1 2 3]])
((fn [a b & x] x) 1 2 3)
(3)
((fn [a & rest] (vector? rest)) 1 2 3)
false
(def a (filter odd? (cycle [:a :b :c :d])))
#'user/a
(list? `(a b c ~@(range 1 4)))
false
(mapcat identity '(((a b) (c d)) ((e f))))
((a b) (c d) (e f))
(clojure.string/replace "xyz" #"x(.)z" (fn [[_ a]] "\1"))
""
((fn [a b] {:a a, :b b}) 1 2)
{:a 1, :b 2}
(case (symbol "b") (a b c) :foo d :bar)
:foo
((fn [x] (let [[a b] x] b)) [1 2])
2
(let [[a b] [1 2 3 4 5]] b)
2
((fn [a & args] (println args)) 1 2 3)
nil
"(2 3)\n"
(into {} (map-indexed vector '[a b c d e]))
{0 a, 1 b, 2 c, 3 d, 4 e}
(map #(vector :record %) '(a b c))
([:record a] [:record b] [:record c])
(clojure.string/replace "xyz" #"x(.)z" (fn [[_ a]] "$1"))
"$1"
((fn [a & option] (or option "default")) nil nil)
(nil)
(eval (list (first '(and a b)) false true))
false
(partition 3 1 '(a b c d e))
((a b c) (b c d) (c d e))
(defmacro show-form [a b] `(println ~@(next &form)))
#'user/show-form
(or "can but it's a royal PITA and/or expensive")
"can but it's a royal PITA and/or expensive"
(let [[a b & cs] (vec (range 200000))] cs)
(2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1...