(let [{:keys [a b], :or {a 1}} {:b 1}] (+ a b))
2
(let [{a :value, b :key, :or {a 10}} {:key "hello"}] [a b])
[10 "hello"]
(let [a (transient {})] (dotimes [x 16] (assoc! a x :ok)) (persistent! a))
{0 :ok, 1 :ok, 2 :ok, 3 :ok, 4 :ok, 5 :ok, 6 :ok, 7 :ok}
(let [a 2 b 3] [(class a) (class b) (/ a b)])
[java.lang.Long java.lang.Long 2/3]
(let [a (hash-map Double/NaN 1)] (identical? (key (first a)) (key (first a))))
true
(let [a '(1 2 3) b (cons 4 a)] [a b])
[(1 2 3) (4 1 2 3)]
(take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
(1 2)
"\"PR1\"\n"
(defn fib [a b] (cons a (lazy-seq (fib b (+ a b)))))
#'user/fib
(take 1 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
(1)
(defmacro bar [a] `(defn foo (when (even? a) a) [] ...))
#'user/bar
(defn arr= [a b] (not (or (< a b) (> a b))))
#'user/arr=
(let [a "s"] (case (str (class a)) "java.lang.String" :found (str (class a))))
"class java.lang.String"
(defn fib [a b] (cons a (lazy-seq (fib b (+ b a)))))
#'user/fib
(clojure.core/defn foo [a b] (clojure.core/let [a 8 b 8] (* a b)))
#'user/foo
(let [a 1 b 2] {:quoted '(a b), :unquoted [a b]})
{:quoted (a b), :unquoted [1 2]}
(for [a [nil [1 2] nil [3 4]] b a] [a b])
([[1 2] 1] [[1 2] 2] [[3 4] 3] [[3 4] 4])
(let [in '[a b a b a b a b]] (apply map list (partition 2 in)))
((a a a a) (b b b b))
(do (loop [a 10] (prn a) (when (> a 0) (recur (- a 1)))) (prn "hello, world"))
nil
"10\n9\n8\n7\n6\n5\n4\n3\n2\n1\n0\n\"hello, world\"\n"
(let [[a b c] (re-matcher #".*test.*" "this is a test. testing. only a test.")] [a b c])
[nil nil nil]
(defn foo "many ways of getting nil" ([]) ([a]) ([a b]) ([a b c]) ([a b c d]))
#'user/foo
(apply (fn ([a b c] (+ a (* b c))) ([a b] (+ a b))) [1 2])
3
(let [a (into-array [1 2 3]) v (vec a)] (aset a 0 42) [(seq a) v])
[(42 2 3) [42 2 3]]
(defn dropcat [a b] (lazy-seq (if (seq a) (cons (first a) (dropcat (rest a) (rest b))) b)))
#'user/dropcat
(map #(apply (fn f ([a] (f :default a)) ([b a] [a b])) %) [[1] [1 2]])
([1 :default] [2 1])
(let [a 1 b 2] [(+ a b) '(+ a b) [+ a b] '[+ a b]])
[3 (+ a b) [#object [clojure.core$_PLUS_ 0x35b52c2b "clojure.core$_PLUS_@35b52c2b"] 1 2] [+ a b]]
(let [a "foo" b (apply str (seq "foo"))] [(identical? a b) (identical? a (get #{a} b))])
[false true]
(for [a (range 20) :while (< a 10) :when (odd? a) :let [b (/ a 2)]] b)
(1/2 3/2 5/2 7/2 9/2)
(defn g [a b] (+ a b))
#'user/g
(let [{a :foo} (seq [:foo :bar])] a)
:bar
(defn foo [a b] (+ a b))
#'user/foo
(let [a 10 a 9] {a 1, a 2})
{9 2, 10 1}
(defn x [a b] (+ a b))
#'user/x
(let [a 1 b 2] {a b})
{1 2}
(let [a "inc"] ((resolve (read-string a)) 1))
2
(read-string "#=(let [a 1] a)")
1
(with-local-vars [a 1] (binding [a 3] @a))
3
(let [{a :a, :or {:a 5}} {}] a)
nil
(if-let [[a b] [false 54]] [a b])
[false 54]
(loop [[a b] [1 2] c a])
nil
(letfn [(a [] (inc (c))) (c [] 3)] (a))
4
(let [[a b] (range 10)] [b a])
[1 0]
(let [a 5] `[a b ~a])
[user/a user/b 5]
(defn me [& a] (boolean (seq a)))
#'user/me
(let [a (atom 1)] (reset! a 2))
2
(with-local-vars [a 10] (var-set a 5) @a)
5
(let [[a b] [1 2]] a b)
2
(let [a 1] [(class a) (class 'a)])
[java.lang.Long clojure.lang.Symbol]
(defn / [a b] (+ a b))
#'user//
(try (let [a (keys [1])] a :ok))
:ok
(let [[a b] [1 2]] [a b])
[1 2]