(let [{a :a} @(atom {:a 42})] a)
42
(defn merge-in [a b] (merge-with merge-in a b))
#'user/merge-in
(when-let [{:keys [a b c]} {:a 2}] a)
2
(let [a 1] `[1 2 a ~a])
[1 2 user/a 1]
(doseq [a '(1 2 3)] (prn a))
nil
"1\n2\n3\n"
(defn mixer [a b] (mapcat vector a b))
#'user/mixer
(let [x :foo {a x} {:foo 1}] a)
1
(-> {:a 1} (as-> {:keys [a]} (+ a)))
1
(if-let [[a b] [nil nil]] [a b] 'else)
[nil nil]
(def x (fn [a b] (+ a b)))
#'user/x
(defn x [a b] (x a b 1))
#'user/x
(defn varargs [a & b] (vector a b))
#'user/varargs
(let [a :foo] (case a :foo (println "YES")))
nil
"YES\n"
(let [a (apply str (range 1e4))] (count a))
38890
(for [{a :a} {:a 1, :b 2}] a)
(nil nil)
(let {a b, 5 6} (+ a b))
11
(let [a [1] b [1]] (identical? a b))
false
(let [{a :keys} {:a 1, :keys 2}] a)
2
(let [a 1 b 2] (+ a b))
3
((fn [a b] + a b) 1 2)
2
(let [a 10 b 20] (+ a b))
30
(let [a 5 b (* 2 a)] b)
10
((fn [a b] (unchecked-multiply a b)) 2984289278487 472737237232)
-3871400209765012080
(let [{{a :a} :b} {:b {:a 0}}] a)
0
(defn make-adder [b] (fn [a] (+ a b)))
#'user/make-adder
(defn key-stuff [{:keys [a b]}] (str a b))
#'user/key-stuff
(let [A true B false] (and A B))
false
(let [a (atom 0)] (swap! a inc) @a)
1
(defprotocol P (foo [a b] [a b c]))
{:methods #{#object [clojure.lang.MultiFn 0xe5b63e2 "clojure.lang.MultiFn@e5b63e2"]}, :name user/P, :ns #object [sci.impl.vars.SciNamespace 0x37a47b18 "user"], :sigs {:foo {:arglists ([a b] [a b c]), :doc nil, :name foo}}}
(let [a 1 b (+ a 2)] b)
3
((fn [& {:as a}] (println a)) :a 1)
nil
"{:a 1}\n"
(let [[_ a b] (range)] (+ a b))
3
(let [a ()] (if-let [x (seq a)] :true-case :false-case))
:false-case
(for [[a b] [[1 2] [3 4]]] a)
(1 3)
(map (fn [a] (Integer/parseInt a)) ["1" "2" "3"])
(1 2 3)
(defn me [& a] (identity (true? (seq a))))
#'user/me
(let [a 5] (list '* 1 2 a))
(* 1 2 5)
(defmulti testfun (fn [a b] (keyword (str a))))
#'user/testfun
(let [a 4 def 5] (+ a def))
9
(defmacro somemacro [] (defn somefn [a b] (a b)))
#'user/somemacro
(do (doseq [a (range 10)] (println a)) nil)
nil
"0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n"
(let [a #() b #()] (= a b))
false
(let [a '6 b '12] (+ a b))
18
(for [a [5] b [1 11]] [a b])
([5 1] [5 11])
(defn put-in [[a b] el] [a el b])
#'user/put-in
(let [[a b] [1 2]] (println a b))
nil
"1 2\n"
((fn [] ((fn [_] (prn "hello, world")) (loop [a 10] (prn a) (when (> a 0) (recur (- a 1)))))))
nil
"10\n9\n8\n7\n6\n5\n4\n3\n2\n1\n0\n\"hello, world\"\n"
(letfn [(f ([a b] (f a b 3)) ([a b c] (+ a b c)))] (->> 10 (f 1)))
14
(sort (comparator (fn [a b] (if (> (count a) (count b)) a (.compareTo a b)))) ["a" "apple" "b" "boo"])
("boo" "b" "apple" "a")
((fn cross [f A B] (for [a A b B] (f a b))) * [1 2 3] [4 5])
(4 5 8 10 12 15)