(= 9 ((fn [] ((fn [a b] (+ a b)) 4 5))))
true
(let [{a 1, b 2} [1 2 3 4]] [a b])
[2 3]
(let [a 1] (some #(= % a) [2 3 1]))
true
(defn f [& {:keys [a b c]}] (+ a b c))
#'user/f
(do (let [a (atom 0)] (defn make-id [] (swap! a inc))) (make-id))
1
((fn [a b & c] [a b c]) 1 2 nil)
[1 2 (nil)]
(let [[a & x] (seq {:a 1, :b 1})] [a x])
[[:a 1] ([:b 1])]
(letfn [(foo [& [a b]] [a b])] (foo 1 2 3))
[1 2]
(let [a (atom 0)] (dotimes [_ 1000] (swap! a inc)) @a)
1000
(sort (map (fn [[a b]] [b a]) {:a 1, :b 2}))
([1 :a] [2 :b])
(merge-with clojure.set/union '([a #{b c}] [a #{d e}]))
([a #{b c}] [a #{d e}])
(defn naive-partial [f a] (fn [b c] (f a b c)))
#'user/naive-partial
(let [[a b c] [1 2 3 4]] [a b c])
[1 2 3]
(let [int-gensym (fn [] (Integer/parseInt (.substring (name (gensym)) 3))) a (int-gensym) b (int-gensym)] [a b (- b a)])
[106348 106349 1]
(defn fib-seq [] ((fn rfib [a b] (->> (+ a b) (rfib b) lazy-seq (cons a))) 1 2))
#'user/fib-seq
(let [a 23] (doseq [b (range 24)] (print (rem (min (- a b) (- b a)) 24))))
nil
"-23-22-21-20-19-18-17-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-10"
(let [a 3 f (fn [%] (+ a %))] (f 5))
8
(letfn [(foo [{:strs [a]}] (println a))] (foo {"a" "Hello", :a "Goodbye"}))
nil
"Hello\n"
(map (fn [a b] (list a b)) (range 5) (range 5))
((0 0) (1 1) (2 2) (3 3) (4 4))
((fn [{:keys [a b]}] (+ a b)) {:a 40, :b 2})
42
(let [a (atom {:a 1})] (swap! a assoc :b 2) @a)
{:a 1, :b 2}
(defn bar [[a b & more]] (+ a b (count more)))
#'user/bar
((fn [a] `(~a '~a)) '(fn [a] `(~a '~a)))
((fn [a] (clojure.core/sequence (clojure.core/seq (clojure.core/concat (clojure.core/list a) (clojure.core/list (clojure.core/sequence (clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list a))))))))) (quote (fn [a] (clojure.core/sequence (clojure.core/seq (clojure.core/concat (clojure.core/list a) (clojure.core/list (clojure.core/sequence (clojure.core/seq (cl...
(defmulti count-cat (fn [c a v] [(:category c) (:action a) (v)]))
#'user/count-cat
(for [a (range 4) b (range 4)] (= a b))
(true false false false false true false false false false true false false false false true)
(apply (fn [a b c] (+ a c)) [1 2 3])
4
(let [[a b & [c]] [1 2]] (list a b c))
(1 2 nil)
(let [[a b] (repeat 10 :foo) #(println "boom!")] [a b])
[:foo :foo]
(let [[_ a _ b] [1 2 3 4]] [a b])
[2 4]
(defn foo [& {:keys [a b c]}] (println a b c))
#'user/foo
(let [{:strs [a b]} {"a" 1, "b" 2}] (list a b))
(1 2)
(defn knit [f g] (fn [[a b]] [(f a) (g b)]))
#'user/knit
(macroexpand-1 '(let [{:as m, a :a} 5] (println a m)))
(let [{a :a, :as m} 5] (println a m))
(let [a {:a :b, :c :d}] (pr-str (map reverse (into [] a))))
"((:b :a) (:d :c))"
(let [{:keys [a b]} {:a 21, :b 2}] (* a b))
42
(let [a 0 _ (println a) b 1] (* 3 b))
3
"0\n"
(let [[[a b] c] [[1 2] 3]] (vector a b c))
[1 2 3]
(let [a {:foo [10 20 30]}] (-> a :foo (nth 1)))
20
(defmacro mydef [a & body] `(def ~(quote a) ~@body))
#'user/mydef
(def f (fn g ([a b] nil) ([a] (g nil nil))))
#'user/f
(doseq [b '(1 2 3) :let [a b]] (println a))
nil
"1\n2\n3\n"
(reduce (fn [a _] (- a)) (- 1) (range 0 6))
-1
(let [a 3 b 4] `(~(+ a b) c))
(7 user/c)
(reduce (fn [a b] (inc a)) 0 '(1 2 3))
3
(doseq [a [1 2] b [:hey :ho]] (println a b))
nil
"1 :hey\n1 :ho\n2 :hey\n2 :ho\n"
(let [{:strs [a b]} {"a" 5, "b" 6}] (+ a b))
11
((fn [& [a & r]] (apply a r)) + 1 2)
3
(let [f (fn [{a "a"}] a)] (f {"a" 1, :a 2}))
1
(defn add-numbers "Adds two numbers together" [a b] (+ a b))
#'user/add-numbers
(defmacro if [test a b] `(if (nil? test) a b))
#'user/if