(let [a (atom 10)] (dotimes [n 5] (swap! a inc)) @a)
15
(distinct (for [a (range 7) b (range 7)] (sort [a b])))
((0 0) (0 1) (0 2) (0 3) (0 4) (0 5) (0 6) (1 1) (1 2) (1 3) (1 4) (1 5) (1 6) (2 2) (2 3) (2 4) (2 5) (2 6) (3 3) (3 4) (3 5) (3 6) (4 4) (4 5) (4 6) (5 5) (5 6) (6 6))
(let [[a b] [1 2 3 4 5]] (list b a))
(2 1)
(for [a [1 2 3] b [9 10 11]] [a b])
([1 9] [1 10] [1 11] [2 9] [2 10] [2 11] [3 9] [3 10] [3 11])
(doseq [[a b] (partition 2 1 (range 5))] (println a b))
nil
"0 1\n1 2\n2 3\n3 4\n"
(defn foo [x y z a] (str x y z a))
#'user/foo
(if false :ORLY (let [a 0 b 1] (+ a b)))
1
(defn f [] (def a 1) (def b 2) (println a b))
#'user/f
(defn foo [str {:keys [a b c]}] [str a b c])
#'user/foo
((fn [& {:keys [a b]}] [a b]) :a 5 :b 6)
[5 6]
(apply (fn [& {:keys [a b c]}] a) (seq {:a 5}))
nil
(let [{:keys [a b]} {:a true, :b false}] (and a b))
false
((fn [a b c] (+ a b c)) 1 2 3)
6
(let [a 2] `(let ~(vector ['a a]) (do whatever)))
(clojure.core/let [[a 2]] (do user/whatever))
(for [a [1 2 3] b [4 5 6]] [a b])
([1 4] [1 5] [1 6] [2 4] [2 5] [2 6] [3 4] [3 5] [3 6])
(defn foo [a b & more] (+ a b (count more)))
#'user/foo
(for [{a :a, :as e} {:a "c", :b "d"}] [a e])
([nil [:a "c"]] [nil [:b "d"]])
(defn compare-by [f] (fn [a b] (compare (f a) (f b))))
#'user/compare-by
((fn [{:strs [a b]}] (+ a b)) {"a" 10, "b" 32})
42
((fn [[a b :as c]] [a b c]) [1 2 3])
[1 2 [1 2 3]]
(loop [[a b & r] "0221caf96a" c ""] (if a (recur r (str c \% a b)) c))
"%02%21%ca%f9%6a"
(macroexpand '(for [a [1 2 3] :when (== a 2) b [7 8 9]] [a b]))
(clojure.core/let [iter__28685__auto__ (clojure.core/fn iter__79825 [s__79826] (clojure.core/lazy-seq (loop [s__79826 s__79826] (clojure.core/when-first [a s__79826] (if (== a 2) (clojure.core/let [iterys__28681__auto__ (clojure.core/fn iter__79827 [s__79828] (clojure.core/lazy-seq (loop [s__79828 s__79828] (clojure.core/let [s__79828 (clojure.core/seq s__79828)] (clojure.core/when s__79828 (if (c...
(let [a (quote (foo (baz 1) (bar 2))) [b c d :as s] a] [a b c d])
[(foo (baz 1) (bar 2)) foo (baz 1) (bar 2)]
(defn test [& {:keys [a b c], :or [a 1 b 2 c 3]}] (+ a b c))
#'user/test
(if-let [[_ a s d f] (re-find #"(a)(s)(d)(f)" "asdf")] [a s d f] :no-match)
["a" "s" "d" "f"]
(let [{:keys [a b c], :or {a 1, b 2, c 3}} {:a 5, :b 6}] [a b c])
[5 6 3]
(let [foo []] (second (reduce (fn [[a x] b] [a (and x (= a b))]) [(first foo) true] (rest foo))))
true
(mapcat (fn [[x :as a]] (if (coll? x) a [a])) '((1 2) (3 4) ((5 6) (7 8))))
((1 2) (3 4) (5 6) (7 8))
(reduce (fn [a b] (if (number? b) (reduced a) (conj a b))) [] [:a :b :c :d 0 :e :f])
[:a :b :c :d]
(let [a {:n (- (+ Integer/MAX_VALUE 1) 1)} b {:n Integer/MAX_VALUE}] (when (= a b) (when (= (hash a) (hash b)) (= {a :z} {b :z}))))
true
(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (.compareTo b a)))) ["a" "booc" "aood" "b"])
("b" "a" "aood" "booc")
(take 5 (drop 400 (for [a (range 10) b (range 10) c (range 10)] [a b c b a])))
([4 0 0 0 4] [4 0 1 0 4] [4 0 2 0 4] [4 0 3 0 4] [4 0 4 0 4])
(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (seq? a) (seq? b)))
(true true true)
(= (mapcat (fn [a] (mapcat (fn [b] [[a b]]) [:a :b :c])) [1 2 3]) (for [a [1 2 3] b [:a :b :c]] [a b]))
true
(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (.compareTo a b)))) ["apple" "a" "booc" "aood"])
("a" "aood" "booc" "apple")
(defn fac [n] (loop [n n a 1] (if (> 2 n) a (recur (dec n) (*' a n)))))
#'user/fac
((fn [& args] (let [{:keys [a b], :or {a 1, b 2}} (apply hash-map args)] [a b])) :a 5)
[5 2]
(defn ab [] (let [a (atom 0)] (fn [x] (if (= x :inc) (swap! a inc) (swap! a dec)) @a)))
#'user/ab
(let [a (lazy-seq (cons (do (println "one") 1) (lazy-seq (cons (do (println "two") 2) nil))))] (first a) (first a))
1
"one\n"
((fn [n] (take n ((fn fib [a b] (cons a (lazy-seq (fib b (+ b a))))) 1 1))) 3)
(1 1 2)
(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (.compareTo a b)))) ["a" "apple" "boo" "b"])
("b" "a" "boo" "apple")
(defn swap!' [a f] (let [old @a new (f old)] (if (compare-and-set! a old new) new (recur a f))))
#'user/swap!'
(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (seqable? a) (seqable? b)))
(true true true)
(let [{a :a, b :b, c :c} {:a 0, :b 1, :c 3}] [c b a b c a])
[3 1 0 1 3 0]
(sort (comparator (fn [a b] (if (> (count a) (count b)) b (.compareTo a b)))) ["a" "apple" "b" "boo"])
("boo" "b" "apple" "a")
((fn [a & args] (if (empty? args) a (recur (conj a (first args)) (rest args)))) nil 1 2 3)
(3 2 1)
(let [a (atom 0) action (delay (swap! a inc)) f #(force a)] [(f) (f) (f)])
[#object [clojure.lang.Atom 0x319f4626 {:status :ready, :val 0}] #object [clojure.lang.Atom 0x319f4626 {:status :ready, :val 0}] #object [clojure.lang.Atom 0x319f4626 {:status :ready, :val 0}]]
(let [a (make-array Integer 2 2) b (aclone a)] (aset a 0 0 (int 2)) (aget b 0 0))
2
(defn ab [] (fn [x] (let [a (atom 0)] (if (= x :inc) (swap! a inc) (swap! a dec)) @a)))
#'user/ab
(let [[a & bs :as v] [1 2 3]] [a bs v])
[1 (2 3) [1 2 3]]