(let [needs-two (fn [a b] (+ a b))] (->> 1 (needs-two 1)))
2
(defn between? [x a b] (and (< x b) (> x a)))
#'user/between?
(macroexpand '(let [a :a b :a] (hash-map a 1 b 2)))
(let [a :a b :a] (hash-map a 1 b 2))
((fn [a b & more] [a b [more]]) 1 2 3 4)
[1 2 [(3 4)]]
(let [{:keys [a b c]} {:a 1, :b 2}] (+ a 2))
3
(doseq [a [1 2 3] b [4 5 6]] (prn [a b]))
nil
"[1 4]\n[1 5]\n[1 6]\n[2 4]\n[2 5]\n[2 6]\n[3 4]\n[3 5]\n[3 6]\n"
(let [syms (for [a (range 4)] (list 'foo a))] `(do ~@syms))
(do (foo 0) (foo 1) (foo 2) (foo 3))
(let [lalala 1] (defn foo [a b c] (println a b c)))
#'user/foo
(let [{a 1, b 2} #{1 2 3 4}] [a b])
[1 2]
(let [a 1 b (+ 2 a) c (* 4 b)] c)
12
(map (fn [q a] {:question q, :answer a}) ["from v1"] ["from v2"])
({:answer "from v2", :question "from v1"})
(apply (fn [a b c & _xs] (+ a b c)) (range))
3
(map (fn [a b] [a b]) [1 2 3] [:a :b :c])
([1 :a] [2 :b] [3 :c])
(for [a [1 2 3] b [4 5 6]] (* a b))
(4 5 6 8 10 12 12 15 18)
((fn [& {a :a, :or {a 10}, :as kwargs}] kwargs) :a "asdfg")
{:a "asdfg"}
(for [a [(atom 0)] x (range 6)] (swap! a (partial + x)))
(0 1 3 6 10 15)
(let [a (atom {:foo 0, :bar 0})] (swap! a update :foo inc))
{:bar 0, :foo 1}
(reductions (fn [a b] (conj a b)) #{} [1 2 3 4])
(#{} #{1} #{1 2} #{1 2 3} #{1 2 3 4})
(defn x [& {:keys [a], :or {a 1}, :as xmap}] (print xmap))
#'user/x
((fn [a f & args] (apply f a args)) 1 + 2)
3
(let [[a b] (split-at 2 [0 1 2 3])] (concat b a))
(2 3 0 1)
(defn foo [n] (let [a (atom n)] #(swap! a + %)))
#'user/foo
(let [[a b & [c]] [1 2 3]] (list a b c))
(1 2 3)
((fn [& {a :a, :or {a 10}, :as kwargs}] kwargs) :an :arg)
{:an :arg}
((fn [& a] (let [b (apply (hash-map) a)] :one b)) :one 2)
2
(reduce (fn ([] nil) ([a b] (conj a (first b)))) [] [[1] [2] [3]])
[1 2 3]
(let [{a :a, b :b} (seq [:a 1 :b 2])] [a b])
[1 2]
(let [a [1 2 3]] (case a [1 _ 3] "ok" "oops"))
"oops"
(let [[a b c] (re-seq #".a." "happy and sad")] [c b a])
["sad" " an" "hap"]
(doseq [:let [result (transient {})] a (range 1 10)] (assoc! result a (rand)))
nil
(mapcat (fn [a b] [a b]) [1 2 3] [:a :b :c])
(1 :a 2 :b 3 :c)
((fn [& [a b :as e]] [a b e]) 1 2 3)
[1 2 (1 2 3)]
((fn [{a :a, b :b}] (+ a b)) {:a 1, :b 2})
3
(let [a (* 2 1) b (* 2 2)] (+ a b))
6
(for [a [[1 2 3] [4 5 6] [7 8 9]]] a)
([1 2 3] [4 5 6] [7 8 9])
(let [a [] b (conj a 1) onedex (dec (count b))] [b onedex])
[[1] 0]
(let [[a b c d e] [1]] [a b c d e])
[1 nil nil nil nil]
(let [v [1 2 3 1 2 4]] (reduce (fn [a b] (if (< (peek a) b) (conj a b) a)) (-> v (get 0) vector) v))
[1 2 3 4]
(merge-with (fn [a b] (if (vector? a) (conj a b) [a b]) {:a (list 1 2 3)} {:a (list 4 5 6)} {:a (list 7 8 9)}))
nil
(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (list? a) (list? b)))
(true false true)
(defn fibonacci [n] (take n ((fn fib [a b] (cons a (lazy-seq (fib b (+ b a))))) 1 1)))
#'user/fibonacci
(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (sequential? a) (sequential? b)))
(true true true)
(let [r (range 1 11)] (for [c r b r :while (< b c) a r :while (< a b) :when (and (= (+ (* a a) (* b b)) (* c c)) (= (+ a b c) 24))] [a b c]))
([6 8 10])
(let [a 1] (do 'a))
a
(first '[a b c])
a
(do (def a 1) @#'a)
1
(defn x ^long [a] 1)
#'user/x
(defn foo [a b c])
#'user/foo
(require '[clojure.set :as a])
nil
(def a '(() () () ({:id 1}) () ()))
#'user/a