(let [h {:foo "bar", :foo2 "bar"}] (map (fn [[k v]] [(name k) (keyword v)]) h))
(["foo" :bar] ["foo2" :bar])
(let [x 1 a (atom x)] (do (swap! a + 5) {:x x, :a @a}))
{:a 6, :x 1}
(let [coll [nil 1 false 2]] (= coll (mapcat #(% identity coll) [filter remove])))
false(let [[f & a] [* 5 3]] [(apply * '(5 3)) (apply f a)])
[15 15]
(let [foo {:a 1, :b 2, :c 3}] (zipmap (keys foo) (map inc (vals foo))))
{:a 2, :b 3, :c 4}
(let [m {:a 1, :b 2}] (into {} (map (fn [[k v]] [k (inc v)]) m)))
{:a 2, :b 3}
(let [s "[^[][['+\ufeff\\"] (->> s (map (comp (partial format "\\u%04x") int)) (apply str)))
"\\u005b\\u005e\\u005b\\u005d\\u005b\\u005b\\u0027\\u002b\\ufeff\\u005c"(let [r (:repeat {:repeat 5} 0)] (if (< r 2) [r] (range 1 (inc r))))
(1 2 3 4 5)
(let [v (vec {:a 1, :b 2, :c 3, :e 4})] [(keys v) (vals v)])
[(:a :b :c :e) (1 2 3 4)]
(let [slash (char-escape-string \\) re-bracket #"\["] (print (clojure.string/replace "foo[bar" re-bracket (str slash \[))))
nil"foo\\[bar"(let [trailing-nl (. "foo" endsWith "o") x (if trailing-nl "" (last ["foo" "bar"]))] (println x))
nil"\n"(defn pivot [p xs] (let [[prior [h & r]] (split-with p xs)] [prior h r]))
#'user/pivot
(let [qs (apply str (repeat 10 "q"))] (map #(.substring qs 0 %) (range 10)))
("" "q" "qq" "qqq" "qqqq" "qqqqq" "qqqqqq" "qqqqqqq" "qqqqqqqq" "qqqqqqqqq")
(let [s #{"a" "b" "c"}] (for [a s b (disj s a)] [a b]))
(["a" "b"] ["a" "c"] ["b" "a"] ["b" "c"] ["c" "a"] ["c" "b"])
(let [m ["the" "quick" "brown" "fox"]] ((juxt (partial apply max-key count) (partial min-key count)) m))
["brown" ["the" "quick" "brown" "fox"]]
(let [x (clojure.string/replace "\ufeffPersonnelNbr" #"\p{Cf}|\p{Cc}" "")] (= (read-string (pr-str x)) x))
true(let [vectors [[1 2 3] [4 5 6]]] (for [x vectors] (map x [0 2])))
((1 3) (4 6))
(let [x (atom 1) _ (do (swap! x inc) (swap! x * 2))] @x)
4(let [{a "ja", b "nein", :or {"nein" "doch"}} {:x 4, "ja" 8}] (println a b))
nil"8 nil\n"(let [{ft true, rm false} (group-by odd? [1 2 3 4 5 6])] [ft rm])
[[1 3 5] [2 4 6]]
(let [thor-x 5 light-x 2] (get {-1 "W", 0 "", 1 "E"} (compare thor-x light-x)))
"E"(let [x (clojure.string/replace "\ufeffPersonnelNbr" #"\p{Cf}|\p{Cc}" "")] (= (read-string (pr-str x)) "\ufeffPersonnelNbr"))
false(let [[a b & xs] [1 2 3 4 5 6 7]] [a b xs])
[1 2 (3 4 5 6 7)]
(let [{:keys [a b c], :or {a 2, b a}} {:c 1}] [a b c])
[2 2 1]
(let [x '(:foo "bar" :baz "spam")] (zipmap (take-nth 2 x) (take-nth 2 (rest x))))
{:baz "spam", :foo "bar"}
(let [{:keys [a b]} {:a 1, :b [1 2], :c {:a :b}}] (println a) b)
[1 2]
"1\n"(loop [b (int 0)] (let [c (loop [a 1] a)] (if false (recur (inc c)))))
nil(defn free? [sym] (let [free (gensym)] (= free (try (eval sym) (catch Exception e free)))))
#'user/free?
(let [maxrange 1000] (reduce + (distinct (into (range 3 maxrange 3) (range 5 maxrange 5)))))
233168(let [maxify (partial clojure.walk/postwalk (partial list 'identity))] (maxify '(+ 3 (* 4 5) 4)))
(identity ((identity +) (identity 3) (identity ((identity *) (identity 4) (identity 5))) (identity 4)))
(let [[x y & more] '(1 2 3 4 5)] (list x y more))
(1 2 (3 4 5))
(let [a (hash-map Double/NaN 1)] [(assoc a Double/NaN 2) (assoc a (key (first a)) 2)])
[{##NaN 1, ##NaN 2} {##NaN 2}]
(let [proc prn coll [1 2 3]] (do (reduce #(proc %2) nil coll) nil))
nil"1\n2\n3\n"(let [{:keys [a b c d]} {:a 0, :b 2, :c 4, :d 8}] d)
8(let [{a :a, b :b, c :c} (seq [:c 1 :b 2])] [a b c])
[nil 2 1]
(let [run [1 2 3] runn (count run)] (do (dorun runn run) (do (dorun run))))
nil(let [s '(1 2 3)] (zipmap s (map #(str "Number: " %) s)))
{1 "Number: 1", 2 "Number: 2", 3 "Number: 3"}
(let [... (fn [& args] (reduce + (map (constantly 3) args)))] (... ... ... ...))
9(let [x (lazy-seq (conj '() (do (println "ein") 1) (do (println "twei") 2)))] (first x))
2"ein\ntwei\n"(let [x '(+ 2 3) op (first x) args (rest x)] (apply op args))
3(let [t (transient {})] (dotimes [n 40] (assoc! t n n)) (reduce + (keys (persistent! t))))
28(let [problems [{:_id 4, :data "TEST"} {:_id 9, :data "SAMPLE"}]] (apply min-key :_id problems))
{:_id 4, :data "TEST"}
(let [v [[1 2] [3 4]] x 5] (conj (pop v) (conj (peek v) x)))
[[1 2] [3 4 5]]
(defn rename [map key new-key] (let [value (map key)] (assoc (dissoc map key) new-key value)))
#'user/rename
(let [v [1 2 3 4 5] [last butlast] (rseq v)] (+ last butlast))
9(let [x [1 2 3 4]] (reduce conj (subvec x 0 1) (subvec x 2)))
[1 3 4]
(let [chunksize (atom 0)] (first (map #(do % (swap! chunksize inc)) (range 100))) @chunksize)
32(let [incrementor (fn [x] (fn [y] (+ x y))) inc2 (incrementor 2)] (inc2 1))
3(defn reloader [f] (let [srv (atom nil)] (fn [] (when @srv (.stop @srv)) (reset! srv (f)))))
#'user/reloader
(let [a (atom false) l (lazy-seq (swap! a not) nil)] [(first (conj l 3)) @a])
[3 true]

