(-> 2 (* 3) (cond-> (= 1 1) inc) (* 2))
14
((fn r [x] (when (< x 2000) (r (inc x)))) 0)
nil
((fn [x] (if (< x 10000) (recur (inc x)) x)) 1)
10000
((fn [x] (if (< x 5) (recur (inc x)) x)) 1)
5
(macroexpand '((->> [1 2 3] (map inc) #(apply +))))
((->> [1 2 3] (map inc) (fn* [] (apply +))))
(take 10 (map take (iterate inc 0) (repeat [1 2 3])))
(() (1) (1 2) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3))
(some-> {:a 0, :b 1} (update-in [:a] inc) (update-in [:b] dec))
{:a 1, :b 0}
(map ({:yes inc, :no dec, :maybe identity} :yes) [1 2 3])
(2 3 4)
(map (fn [x] (inc x)) '(1 2 3 4 5))
(2 3 4 5 6)
(reduce #(assoc % (inc %2) (dec %2)) {} [1 2 3])
{2 0, 3 1, 4 2}
(map (comp first (juxt identity (comp prn inc))) [1 2 3])
(1 2 3)
"2\n3\n4\n"
(->> [1 2 3 4 5 6] (map inc) (take 2))
(2 3)
(loop [x 1] (if (= x 5) :done (recur (inc x))))
:done
(let [afn (fn [i] inc i)] (map afn [1 2 3]))
(1 2 3)
(let [s "foo bar"] (.substring s 0 (inc (.indexOf s " "))))
"foo "
(defn make-counter [init] (let [state (atom (dec init))] (fn [] (swap! state inc))))
#'user/make-counter
(letfn [(priv-fn [x] (inc x))] (defn pub-fn [x] (priv-fn (* 2 x))))
#'user/pub-fn
(#(str (subs % 0 %2) (subs % (inc %2))) "abcd" 1)
"acd"
(-> [1 2] (as-> [x y] [(inc y) (dec x)] [y x]))
[0 3]
(let [a (atom 0) b (fn [] (swap! a inc))] [(b) (b) (b)])
[1 2 3]
(meta (second (macroexpand-1 '(defcomp foo "bar" [a b c] inc dec))))
nil
(take 5 (keep-indexed #(when (even? %2) [%1 %2]) (iterate inc 0)))
([0 0] [2 2] [4 4] [6 6] [8 8])
(defn foo [] ((fn rec [i] (lazy-seq (cons i (rec (inc i))))) 0))
#'user/foo
(take 5 (iterate (fn [x] (print "f: " x) (inc x)) 1))
(1 2 3 4 5)
"f: 1f: 2f: 3f: 4"
(let [binding 'x body '(inc x)] `(let [~binding 10] ~body))
(clojure.core/let [x 10] (inc x))
(if (== (+ 1 1) 2) (-> 5 inc) (-> 4 dec))
6
(take 5 (apply (fn [& xs] (filter odd? xs)) (iterate inc 0)))
(1 3 5 7 9)
((fn to-five [x] (if (< 5 x) (to-five (inc x)) x)) 1)
1
(take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
(1 2)
"\"PR1\"\n"
(loop [x 42] (if (zero? x) :heyhey (recur ((rand-nth [inc dec]) x))))
:heyhey
(reduce #(if (even? %2) (conj %1 (inc %2)) %1) [] (range 10))
[1 3 5 7 9]
(update-in {:a {:b [45 88 {:c 5}]}} [:a :b 2 :c] inc)
{:a {:b [45 88 {:c 6}]}}
(reduce #(assoc % %2 (inc (% %2 0))) {} "foo bar baz")
{\space 2, \a 2, \b 2, \f 1, \o 2, \r 1, \z 1}
(take 10 (map (juxt identity #(* % %)) (iterate inc 0)))
([0 0] [1 1] [2 4] [3 9] [4 16] [5 25] [6 36] [7 49] [8 64] [9 81])
(-> (update-in {} [:first] (fnil inc 0)) (update-in [:second] (fnil conj []) :value))
{:first 1, :second [:value]}
(take 1 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
(1)
(let [f #(if (= % 7) [:hi 6 6] :hi) g inc h inc] (= ((comp f g h) 5) ((juxt f g h) 5)))
true
(let [a (atom {:foo 0, :bar 0})] (swap! a update :foo inc))
{:bar 0, :foo 1}
(apply hash-map (for [[k v] {:foo 1, :bar 2}] [k (inc v)]))
{[:foo 2] [:bar 3]}
(vec (map (fn [[key value]] [(inc key) value]) [[0 :a] [1 :b]]))
[[1 :a] [2 :b]]
(binding [*read-eval* true] (eval (read-string "(defn foo [x] (inc x))")))
#'user/foo
(let [s (range 10)] (->> s (map inc) (filter even?) (take 3)))
(2 4 6)
(-> 10 (* 2) (as-> x (if (even? x) x (inc x))))
20
(let [a 1 b (inc a)] (+ a a b b b))
8
(do (def xf3 (comp (map inc) (filter odd?))) (into [] xf3 (range 6)))
[1 3 5]
(defn d [count sides] (apply + (repeatedly count #(inc (rand-int sides)))))
#'user/d
(let [a-fn (fn [x] (map inc x))] (-> [1 2 3] a-fn))
(2 3 4)
(into {} (for [[k v] {:foo 12, :bar 34}] [(str k) (inc v)]))
{":bar" 35, ":foo" 13}
(let [f (fn [x & y] x)] (apply f (iterate inc 0)))
0
(filter #(zero? (rem 12 %)) (range 2 (inc (/ 12 2))))
(2 3 4 6)