(let [base [1 2 3 5 6 8]] (map - base (drop 1 (cycle base))))
(-1 -1 -2 -1 -2 7)
(defn take-only [n coll] (let [c (take n coll)] (when (= (count c) n) c)))
#'user/take-only
(let [v [10 11 12 13 14]] (concat (subvec v 0 2) (subvec v 3)))
(10 11 13 14)
(let [m {:a :b, :b :c, :c :d}] (take-while identity (iterate (partial get m) :a)))
(:a :b :c :d)
(let [r (:repeat {:repeat 1} 0)] (if (< r 2) [r] (range 1 (inc r))))
[1]
(let [x [1 2 3 4]] (reduce conj (subvec x 0 2) (subvec x 3)))
[1 2 4]
(let [nested-seq [[1 2 3] [:a :b :c] [] ["heh"]]] (for [seq nested-seq x seq] x))
(1 2 3 :a :b :c "heh")
(defn tramp [handler] (fn [req] (let [x (handler req)] (if (fn? x) (x req) x))))
#'user/tramp
(defmacro dbg [x] `(let [x# ~x] (println "dbg:" '~x "=" (with-out-str (pr x#))) x#))
#'user/dbg
(let [{t true, f false} (group-by even? (range 10))] [(first t) (concat (rest t) f)])
[0 (2 4 6 8 1 3 5 7 9)]
(let [m {:three 3, :five 4, :four 4}] (->> m seq (apply max-key second) first))
:four(let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))
["a" "b" "c"]
(let [x (cons (do (println "eins") 1) (cons (do (println "zwei") 2) nil))] (first x))
1"eins\nzwei\n"(let [make-adder (fn [a] (fn [x] (+ a x))) adder-5 (make-adder 5)] (adder-5 10))
15(meta (let [discard #(with-meta % nil)] (binding [*data-readers* {'foo discard}] (read-string "^:bar #foo []"))))
{:bar true}
(let [{:keys [a b c], :as all, :or {b 2, c 3}} {}] [a b c])
[nil 2 3]
(let [state (atom {:plots [[1 2] [1 5]]})] (swap! state update-in [:plots 0 1] inc))
{:plots [[1 3] [1 5]]}
(let [{:keys [a b c], :or {c 0}, :as args} {:a 1, :b 2}] c)
0(let [bits [1 0 1 0 1 0]] (map (partial take-nth 2) [bits (rest bits)]))
((1 1 1) (0 0 0))
(let [a 1 b 2 _ (println a b) c 3] (+ a b c))
6"1 2\n"(let [nth-arg (fn [n & args] (nth args n))] (apply nth-arg 99 (iterate inc 44)))
143(let [y "\ufeffPersonnelNbr" x (clojure.string/replace y #"\p{Cf}|\p{Cc}" "")] (= x y))
false(let [v [10 11 12 13 14]] (concat (subvec v 0 2) (subvec v 2)))
(10 11 12 13 14)
(let [lines [[3 2 3] [5 7 1]]] (map-indexed (fn [i x] [x i]) lines))
([[3 2 3] 0] [[5 7 1] 1])
(defmacro f+g [f g x] `(let [x# ~x] (if (~f x#) (~g x#) x#)))
#'user/f+g
(let [delim "^"] (str "[" (->> delim first int (Integer/toHexString) (str "\\u")) "]"))
"[\\u5e]"(let [a (atom 0) foo (constantly (do (swap! a inc) :hi))] (foo) (foo) (foo) @a)
1(let [a (atom 4)] (swap! a inc) (prn a) (swap! a + 10) (prn a))
nil"#object[clojure.lang.Atom 0xf71769d {:status :ready, :val 5}]\n#object[clojure.lang.Atom 0xf71769d {:status :ready, :val 15}]\n"(let [m0 {} m1 (assoc m0 :a 0) m2 (assoc m1 :b 2)] [m0 m1 m2])
[{} {:a 0} {:a 0, :b 2}]
(let [v (vec (range 20))] (class (into (subvec v 0 10) (subvec v 14 20))))
clojure.lang.APersistentVector$SubVector(let [b (map (fn [x] (println x)) '(1 2 3))] (doall b) (doall b))
(nil nil nil)
"1\n2\n3\n"(macroexpand '(clojure.test/are [x y] (let [y (+ x y)] (= y x)) 0 0))
(clojure.test/are [x y] (let [y (+ x y)] (= y x)) 0 0)
(let [<c #(apply < (mapv int %&))] (filter #(<c \A % \Z) "AbCdEfGh"))
(\C \E \G)
(let [{[f & r] :items} {:hp 100, :mana 10, :items '[sword bread]}] [f r])
[sword (bread)]
(let [foo #(partial conj (empty %))] ((foo '(1 2 3)) 4 5 6))
(6 5 4)
(let [m {"a" 1, "b" 2, "c" 3}] (m (some #(re-matches #"a$" %) (keys m))))
1(defn char-seq [br] (let [c (read br)] (when-not (= c -1) (cons c (lazy-seq (char-seq br))))))
#'user/char-seq
(let [x (atom false)] (filter (fn [_] (swap! x not)) [1 2 3 4 5 6]))
(1 3 5)
(let [adder (fn [x] #(+ x %))] (do (println (type (adder 3))) (type (adder 3))))
sci.impl.fns$fun$arity_1__26688"sci.impl.fns$fun$arity_1__26688\n"(let [x [] y (conj x '(filter #(= 3 %) (range 1000)))] (comment "blah blah"))
nil(#(let [& 1 % 2] (str %& %1 %2 %3)) 3 4 5 6 7)
"(6 7)245"(let [n1 -5.0 n2 -5.0] [(= n1 n2) (= #{n1} #{n2}) (= [n1] [n2])])
[true true true]
(let [triangle (for [i (range 5)] (range i))] (for [row (range (count triangle))] (nth triangle row)))
(() (0) (0 1) (0 1 2) (0 1 2 3))
(let [input {1 :a, 2 :b, 3 :c, 4 :d}] (select-keys input (filter even? (keys input))))
{2 :b, 4 :d}
(let [m {:key :whatever, :values []} new-vals [5 5]] (assoc-in m [:values] (mapv (partial hash-map :value) new-vals)))
{:key :whatever, :values [{:value 5} {:value 5}]}
(let [data [{:records [{:id 1} {:id 2}]}]] (for [{records :records} data {id :id} records] id))
(1 2)
(let [a "yep" b ""] (cond-> {} (seq a) (assoc :a a) (seq b) (assoc :b b)))
{:a "yep"}
(let [xs [[1 2] [3 4]]] (zipmap (map (comp keyword str first) xs) (map second xs)))
{:1 2, :3 4}
(let [splitter 1 coll [:a :b :c :d]] (mapv vec [(take splitter coll) (drop splitter coll)]))
[[:a] [:b :c :d]]
(let [[a b c d] (map inc [1 2 3 4])] (println a b c d))
nil"2 3 4 5\n"

