((fn [a b & x] [a b x]) 1 2 3 4)
[1 2 (3 4)]
((fn [& [{:keys [a b]}]] (+ a b)) {:a 1, :b 2})
3
(defn foo [a b & {:keys [key1 key2]}] [a b key1 key2])
#'user/foo
(defn foo1 [{x :a, y :b, :as a}] (println x y a))
#'user/foo1
((fn f [a {:keys [b]}] (+ 1 a b)) 1 {:b 2})
4
(let [{a "ja", b "nein"} {:x 4, "ja" 8}] (println a b))
nil
"8 nil\n"
(for [a [1 2 3] b '[x y]] [a b])
([1 x] [1 y] [2 x] [2 y] [3 x] [3 y])
(let [a [1 2 3] [_ b] a] (= b 2))
true
(defmacro testmacro ([a b] (list 'clojure.core/+ a b)) ([] (list 'user/testmacro 1 2)))
#'user/testmacro
(defn yielder [s] (let [a (atom s)] (fn [] (first (swap! a next)))))
#'user/yielder
((fn [f a b] ((resolve f) a b)) (read-string "+") 2 3)
5
(let [a {:name nil, :address nil} b (assoc a :name "cark")] b)
{:address nil, :name "cark"}
(do (require ['clojure.walk :as 'walk]) (walk/macroexpand-all '(quote (let [a 1] a))))
(quote (let [a 1] a))
(reduce (fn ([] nil) ([a b] (into a b))) [] [[1] [2] [3 4]])
[1 2 3 4]
(for [a [1 2 3] b [4 5 6]] (+ a b))
(5 6 7 6 7 8 7 8 9)
(reduce (fn [a b] (/ b a)) [1 2 3 4 5])
15/8
(map (fn [[a b c]] [a c]) (partition-all 3 (range 1 7)))
([1 3] [4 6])
(apply (fn [a b c] (println a b c)) 6 [7 8])
nil
"6 7 8\n"
(let [{a 1, b 2} (take 4 (iterate inc 1))] [a b])
[2 nil]
(for [[k v] [[1 2] ["x" "y"]] :let [a (str k)]] a)
("1" "x")
((fn [{a :a, b :b}] (+ a b)) {:a 1, :b 8})
9
(defn make-operator [x] (let [myx x] (fn [a b] (myx a b))))
#'user/make-operator
(let [a (atom {:a {}, :b {}})] (swap! a update-in [:b] assoc :data 10))
{:a {}, :b {:data 10}}
(macroexpand '(let [{:or {a 1}, a :a, b :b} {:b 2}]))
(let [{a :a, b :b, :or {a 1}} {:b 2}])
(for [[a b] (map list (range 10) (range 20))] (* a b))
(0 1 4 9 16 25 36 49 64 81)
((fn f ([a] (f a 2)) ([b c] (+ b c))) 8)
10
(let [[a & b] '(1 2 3)] {:a a, :b b})
{:a 1, :b (2 3)}
(let [a (atom 1)] (prn @a) (reset! a 2) (prn @a) nil)
nil
"1\n2\n"
(for [a [1 2 3] b [1 1 1]] (= a b))
(true true true false false false false false false)
(let [a (atom 0) b (fn [] (swap! a inc))] [(b) (b) (b)])
[1 2 3]
((fn [& {:keys [a b], :or {b 10}}] [a b]) :a 9)
[9 10]
(let [a {:a :b, :c :d}] (str (seq (map reverse (into [] a)))))
"((:b :a) (:d :c))"
(let [cool (fn cool [a b] (+ a b))] (cool 4 5))
9
((fn [a b & [more]] [a b more]) 1 2 [3 4])
[1 2 [3 4]]
(let [{a 1, b 2} '(1 2 3 4)] [a b])
[2 nil]
(for [a [1 2 3] b [:x :y]] {:a a, :b b})
({:a 1, :b :x} {:a 1, :b :y} {:a 2, :b :x} {:a 2, :b :y} {:a 3, :b :x} {:a 3, :b :y})
((fn [[a & b]] (into [a 2] b)) [1 2 3 4])
[1 2 2 3 4]
((fn [a b & more] [a b more]) 1 2 3 4)
[1 2 (3 4)]
(for [a [1 2 3] but [7 8]] (println a "." but))
(nil nil nil nil nil nil)
"1 . 7\n1 . 8\n2 . 7\n2 . 8\n3 . 7\n3 . 8\n"
(reduce (fn [a x] (+ a (count x))) 0 ["alice" "bob" "carol"])
13
(reduce conj #{} '(a b a c d g g w))
#{a b c d g w}
(let [plus (fn [a b] (+ a b))] (reductions + (range 5)))
(0 1 3 6 10)
(take 15 (iterate (fn [[a b]] [b (+ a b)]) [1 0]))
([1 0] [0 1] [1 1] [1 2] [2 3] [3 5] [5 8] [8 13] [13 21] [21 34] [34 55] [55 89] [89 144] [144 233] [233 377])
(into #{} (for [a (range 7) b (range 7)] (sort [a b])))
#{(0 0) (0 1) (0 2) (0 3) (0 4) (0 5) (0 6) (1 1) (1 2) (1 3) (1 4) (1 5) (1 6) (2 2) (2 3) (2 4) (2 5) (2 6) (3 3) (3 4) (3 5) (3 6) (4 4) (4 5) (4 6) (5 5) (5 6) (6 6)}
(let [x (atom [1 2])] (swap! x (fn [[a b]] [b a])))
[2 1]
(map-indexed (fn [a b] [(inc a) b]) [:a :b :c :d :e])
([1 :a] [2 :b] [3 :c] [4 :d] [5 :e])
((fn [& {:keys [a b]}] (+ a b)) :a 1 :b 2)
3
(let [[a b c & d] (range 10)] [a b c d])
[0 1 2 (3 4 5 6 7 8 9)]
(let [[a b c] '(1 2 3)] (vector a b c))
[1 2 3]
((fn [& {:keys [a b]}] (+ a b)) :a 5 :b 10)
15