(let [a 0 b (inc a) c (inc b) d (inc c)] d)
3
(let [[a b c d] (seq (set (range 10)))] [a b c d])
[0 7 1 4]
(let [{:strs [a b]} {"a" 1, "b" 3, "c" 3}] (+ a b))
4
((fn [& {:keys [a b c]}] {:pre [a b c]} (+ a b c)) :a 0 :b 1 :c 2)
3
(for [[prefix & suffixes] '((a (b c) (c b)) (b (a c) (c a))) suffix suffixes] (conj suffix prefix))
((a b c) (a c b) (b a c) (b c a))
((fn fact ([n] (fact 1 n)) ([a n] (if (= n 1) a (recur (* n a) (dec n))))) 20)
2432902008176640000
(defn rangemap [x a b a' b'] (+ a' (* (- x a) (/ (- b' a') (- b a)))))
#'user/rangemap
(let [m {:thinga [{:a1 "x", :a2 "y"}]} {[{a :a1}] :thinga} m] a)
"x"
(doseq [[a b] (partition 2 [1 2 3 4])] (prn (+ a b)))
nil
"3\n7\n"
(for [[a b] (map list (range 10) (range 10 20))] (* a b))
(0 11 24 39 56 75 96 119 144 171)
(let [a (range 1 12)] (format "%s" (apply str (interleave " " a))))
" 1"
(let [{:keys [a b c]} {:a 10, :c 30}] (prn a b c))
nil
"10 nil 30\n"
(let [{a :a, b :b, :as m, :or {a "a0", b "b0"}} {}] m)
{}
(let [pow (fn [a b] (reduce * (repeat a b)))] (pow 2 3))
9
(apply (fn [a b c] (+ a (* b c))) [1 2 3])
7
(let [{a :a, :as m} '(1 2 :a 4)] (println a m))
nil
"4 {1 2, :a 4}\n"
(defn flip [f] (fn [a b & args] (apply f b a args)))
#'user/flip
(let [a (atom 0) d (delay (swap! a inc))] [@d @d @d])
[1 1 1]
(defn fun3 [[a b c :as s]] (when (= a b c) s))
#'user/fun3
(remove #(= 'a %) '[b c a d a f g])
(b c d f g)
(let [f (fn [a] (let [list [1 2 3]] (a list)))] (f list))
([1 2 3])
(read-string "['(quoted a b c) `(quasiquoted a b c)]")
[(quote (quoted a b c)) (clojure.core/sequence (clojure.core/seq (clojure.core/concat (clojure.core/list (quote user/quasiquoted)) (clojure.core/list (quote user/a)) (clojure.core/list (quote user/b)) (clojure.core/list (quote user/c)))))]
(for [a [1 2 3] b [4 5 6]] {:a a, :b b})
({:a 1, :b 4} {:a 1, :b 5} {:a 1, :b 6} {:a 2, :b 4} {:a 2, :b 5} {:a 2, :b 6} {:a 3, :b 4} {:a 3, :b 5} {:a 3, :b 6})
(first (nth (iterate (fn [[a b]] [b (+ a b)]) [1 1]) 5))
8
((fn [a b & more] [a b [more]]) 1 2 3 4 5)
[1 2 [(3 4 5)]]
(let [a (atom 1) f (swap! a inc)] `(if ~f (~f)))
(if 2 (2))
((fn [a b] ((fn [x y] (+ x y)) a b)) 2 3)
5
(defn x [& {:keys [a b c]}] {:a2 a, :b2 b, :c2 c})
#'user/x
(let [{[a b :as c] :val} {:val [1 2 3]}] [a b c])
[1 2 [1 2 3]]
(let [a (range 1 12)] (format "%s" (apply str (interpose " " a))))
"1 2 3 4 5 6 7 8 9 10 11"
((fn [& {:keys [a b c]}] [a b c]) :b 2 :a 1)
[1 2 nil]
(let [[a :as [b :as [c :as [d]]]] (range)] [a b c d])
[0 0 0 0]
((fn [{:keys [a b]}] (vector a b)) {:a 1, :b 2, :c 'nope})
[1 2]
(map (fn [a b] (+ a b)) [1 2 3] [300 200 100])
(301 202 103)
(for [a [1 2 3] b [10 11 12]] (+ a b))
(11 12 13 12 13 14 13 14 15)
(let [a 'foo b `~(vary-meta a assoc :example true)] [b (meta b)])
[foo {:example true}]
(let [l '(1 2 3)] (let [[a & [b]] l] [a b]))
[1 2]
((fn [& [a b c & z]] [a b c z]) (range 10))
[(0 1 2 3 4 5 6 7 8 9) nil nil nil]
(for [a (range 1 11) b (range 1 11) c (range 1 11) :when (= (* c c) (+ (* a a) (* b b))) :when (= 24 (+ a b c))] [a b c])
([6 8 10] [8 6 10])
(defn foo [a &rest [b]] (let [b (or b 'default-b)] (list a b)))
#'user/foo
(macroexpand '(let [{:or {a 1, b 2}, a :a, b :b} nil]))
(let [{a :a, b :b, :or {a 1, b 2}} nil])
((fn [a b & more] [a b more]) 1 2 3 4 5)
[1 2 (3 4 5)]
(take-while (fn [[a b]] (not= a b)) [[0 1] [0 0] [3 4]])
([0 1])
(let [[a [& b]] [1 '([2 3] [4 5])]] (cons a b))
(1 [2 3] [4 5])
(let [{:keys [a], :as m} {:a 42, :b 11}] [a (dissoc m :a)])
[42 {:b 11}]
(apply (fn between? [x a b] (< a x b)) 5 [2 9])
true
(let [a (atom 1)] (swap! a (fn [val i] (+ val i)) 1))
2
(macroexpand '(domonad maybe-m [a (when true 1) b (inc a)] (inc b)))
(domonad maybe-m [a (when true 1) b (inc a)] (inc b))
((fn [a b & [more]] [a b more]) 1 2 [3 4 5])
[1 2 [3 4 5]]
(let [a (atom 0)] (while (> 10 @a) (swap! a inc)) (println @a))
nil
"10\n"