(let [[a & [b c] :as all :or {b 2, c 3}] [1]] [a b c])
[1 nil nil]
(apply (fn [& {:keys [a b]}] [":a" a ":b" b]) (apply concat {:a 1, :b 2}))
[":a" 1 ":b" 2]
(reduce-kv (fn [a k [v]] (assoc a k v)) {} {:foo [{:bar :baz}], :bar [{:baz :bop}]})
{:bar {:baz :bop}, :foo {:bar :baz}}
(let* [vec__8134 [1 2] a (clojure.core/nth vec__8134 0 nil) b (clojure.core/nth vec__8134 1 nil)] [a b])
[1 2]
(let [a [1 2] b [3 4] c [5 6]] ((juxt concat interleave) a b c))
[(1 2 3 4 5 6) (1 3 5 2 4 6)]
(for [[a b] (map list [1 2 nil 4] [5 6 7 8])] (or a b))
(1 2 7 4)
((fn [& [a b :as {:keys [f], :or {f 5}}]] [a b :f f]) :a 3)
[:a 3 :f 5]
(re-matches #"(?x)a b #well, this is a very cool pattern, don't you think?" "ab")
"ab"
(defn hello [a & more] (str "Hello to: " (clojure.string/join ", " (cons a more)) "!"))
#'user/hello
((fn [& all] (let [xall (butlast all) last2 (last all)] (doall (map #(let [a %] (if (fn? a) (a) a)) xall)) (last2))) #(println 1) #(do 2) #(do 3) 4 #(do 5))
5
"1\n"
(clojure.walk/postwalk #(if (coll? %) % (str %)) '((E (C) (F I) F) (A A) H ((G) B) ((E G (I (I I A)) H I) (B) (A) C (D (H))) (F C C)))
(("E" ("C") ("F" "I") "F") ("A" "A") "H" (("G") "B") (("E" "G" ("I" ("I" "I" "A")) "H" "I") ("B") ("A") "C" ("D" ("H"))) ("F" "C" "C"))
(mapcat (fn [[a b]] [a (* b 2)]) (partition 2 (list :a 1 :b 2 :c 3)))
(:a 2 :b 4 :c 6)
(reduce (fn [acc path] (update-in acc path (fnil inc 0))) {} '((a b c) (a b d)))
{a {b {c 1, d 1}}}
(reduce #(%1 %2) (fn [a] (fn [b] (fn [c] (+ a b c)))) [1 2 3])
6
((fn [a b] (or (first (remove zero? (map compare a b))) 0)) [1 2 3] [2 3])
-1
(defn fibber [n] (take n (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1]))))
#'user/fibber
((fn [a b] (or (first (remove zero? (map compare a b))) 0)) [4 2 3] [2 3])
1
(defn filter-indexed [f coll] (map second (filter (fn [[a b]] (f a b)) (map vector (range) coll))))
#'user/filter-indexed
(let [v [1 2 3 4 5 6] [a b] (split-at 3 v)] (concat a (next b)))
(1 2 3 5 6)
(defn fibber [n] (take n (map first (iterate (fn [[a b]] [b (a + b)]) [0 1]))))
#'user/fibber
((fn [a & {:keys [b c d]}] [:args a b c d]) 1 :c 3 :d 4)
[:args 1 nil 3 4]
(let [a (atom '[x [y z]])] (first (swap! a (fn [[_ [f & more]]] [f more]))))
y
(let [[a b c :as x] [1 nil 2]] (if (every? identity x) [a b c] :otherwise))
:otherwise
(take 10 (apply (fn [a b & args] (concat [a b] args)) (concat [1 2] (repeat 1))))
(1 2 1 1 1 1 1 1 1 1)
(let [a 1 b 2 c 3] (map (fn [e] (keyword (:name (meta #'e)))) [a b c]))
(nil nil nil)
(let [[a b c :as d :as e] [1 2 3 4 [5 6]]] [a b c])
[1 2 3]
(for [[a b c] (partition 3 '(1 2 3 4 5 6))] (list c b a))
((3 2 1) (6 5 4))
(defn fibber [n] (take n (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1]))))
#'user/fibber
((fn [a] (do (println "swaped out: " @a) (println "swaped in: " (swap! a inc)))) (atom 0))
nil
"swaped out: 0\nswaped in: 1\n"
((fn [& {:keys [a b], :as opts, :or {b 3}}] [a b opts]) :c 2 :a 4)
[4 3 {:a 4, :c 2}]
(reduce (fn [acc path] (update-in acc path (fnil inc 0))) {} '((a b c) (a b c)))
{a {b {c 2}}}
(let [make-seq (fn make-seq [start-value] (lazy-seq (cons start-value (make-seq (inc start-value))))) a (make-seq 1)] (take 4 a))
(1 2 3 4)
(let [{a :a, b :b} {:a 5, :b 6} [x y] (range 2)] [a b x y])
[5 6 0 1]
(let [[a b c *xs] '(1 2 3 4 5 6 7)] (+ a b c))
6
((fn [{a :a, c :b, :as m}] (prn a c m)) {:a 1, :b 2, :c 3})
nil
"1 2 {:a 1, :b 2, :c 3}\n"
(let [m {:foo "foo", :bar "bar"}] (merge m (apply hash-map (mapcat (fn [[a b]] [b a]) m))))
{:bar "bar", :foo "foo", "bar" :bar, "foo" :foo}
(partition 2 (interleave '(a b c d e) (rest (cycle '(a b c d e)))))
((a b) (b c) (c d) (d e) (e a))
(defn comp-- ([] identity) ([f] f) ([f & gs] (fn [& a] (f (apply (apply comp-- gs) a)))))
#'user/comp--
((fn repr-record [{:keys [a b]}] (prn-str "a record:" a b)) {:a "hello, world", :b 23, :c "abc"})
"\"a record:\" \"hello, world\" 23\n"
(let [m {:foo 1, :bar 2}] (map (fn [a b] '(a b)) (keys m) (vals m)))
((a b) (a b))
(do (defmacro cartesian [& args] `(for ~@args)) (cartesian [a (range 3) b (range 3)] [a b]))
([0 0] [0 1] [0 2] [1 0] [1 1] [1 2] [2 0] [2 1] [2 2])
((fn [a b & cs] (prn a b) (if cs (recur (+ a (first cs)) (second cs) (nnext cs)))) 1 :a 2 :b 3 :c 4 :d)
nil
"1 :a\n3 :b\n6 :c\n10 :d\n"
(some #{'+} '[- a +])
+
(defn a [b _ _ c] b)
#'user/a
(let [a 1 b 2 c 3])
nil
(macroexpand '(cond a b c d))
(if a b (clojure.core/cond c d))
(some #{'c} '(a b c))
c
(let [a 5] `(~a b c))
(5 user/b user/c)
(map vector '[a b c] (range))
([a 0] [b 1] [c 2])
(:clj [(def a 1) (def b 2)])
nil