(if 1 (defn f [x] (inc x)) (defn f [x] (dec x)))
#'user/f
(some #(when (pos? %) (inc %)) [-2 -1 0 1 2])
2
(map-indexed #(assoc %2 :rank (inc %1)) (list {:o :a} {:o :b}))
({:o :a, :rank 1} {:o :b, :rank 2})
(into [] (map (fn [[key value]] [(inc key) value]) [[0 :a] [1 :b]]))
[[1 :a] [2 :b]]
(take 5 ((fn incs [i] (lazy-seq (cons i (incs (inc i))))) 1))
(1 2 3 4 5)
(map-indexed #(if (even? %1) (inc %2) %2) [1 2 3 4])
(2 2 4 4)
(defn blerp "good for incrementing stuff, deserves to live" [n] (inc n))
#'user/blerp
(map apply [inc dec + -] [[1] [43] [8 17] [1000 33]])
(2 42 25 967)
(apply str (map #(apply str (repeat (inc (rand-int 10)) %)) "Clojure"))
"CClllllloooooojjjjjjuuuurrrrrrrrreeee"
(defn map-count [amap key] (assoc amap key (inc (get amap key 0))))
#'user/map-count
(apply (constantly nil) (for [x (take 20 (iterate inc 1))] (print x)))
nil
"12"
(nth ((fn f [n] (lazy-seq (concat [n] (f (inc n))))) 1) 1e5)
100001
(apply (fn [x y & etc] (+ x y)) (iterate inc 0))
1
((fn [f a] (zipmap a (map f a))) inc [1 2 3])
{1 2, 2 3, 3 4}
(for [x [nil 1 2 false true] :when (number? x)] (inc x))
(2 3)
(map (fn [[k v]] [(str k) (inc v)]) {:foo 12, :bar 34})
([":foo" 13] [":bar" 35])
(transduce (map inc) (completing conj! persistent!) (transient []) [1 2 3 4 5])
[2 3 4 5 6]
(map (fn [a b] [a b]) [1 2 3] (iterate inc 0))
([1 0] [2 1] [3 2])
(take 10 ((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10))
(10 11 12 13 14 15 16 17 18 19)
(map-indexed #(if (odd? %1) %2 (inc %2)) [1 2 3 4])
(2 2 4 4)
(into {} (map (fn [[k v]] [k (inc v)]) {:a 1, :b 2}))
{:a 2, :b 3}
(apply (apply comp (list + inc -)) '(1 2 3 4))
-7
(map #(%1 %2) (cycle [inc identity]) [1 1 1 1 1])
(2 1 2 1 2)
(map (fn [[_ v]] (inc v)) {:a 1, :b 2, :c 3})
(2 3 4)
(defn fac [n] (reduce #(* %1 %2) (range 1 (inc n))))
#'user/fac
(let [v [1 2 3 4]] (conj (pop v) (inc (peek v))))
[1 2 3 5]
(map inc (take 3 (drop 2 [2 5 4 1 3 6])))
(5 2 4)
(let [name "Michael" my-data {name (atom 22)}] (swap! (my-data name) inc) my-data)
{"Michael" #object [clojure.lang.Atom 0x26ce071f {:status :ready, :val 23}]}
(for [a [[1 2 3] [4 5 6]] b a] (inc b))
(2 3 4 5 6 7)
(map (fn [x i] [x i]) [:a :b :c] (iterate inc 0))
([:a 0] [:b 1] [:c 2])
(let [vec [2 3 4 5]] (conj (pop vec) (inc (peek vec))))
[2 3 4 6]
(take 5 (iterate (fn [[x y]] [(inc x) (dec x)]) [0 0]))
([0 0] [1 -1] [2 0] [3 1] [4 2])
(map #(-> [1 (inc %) 2 (dec %) 3]) [5 10 15])
([1 6 2 4 3] [1 11 2 9 3] [1 16 2 14 3])
(defn adding [x y] (if (= x 0) y (inc (+ dec x))))
#'user/adding
(map #(if (even? %2) (inc %1) %1) [1 2 3 4] (range))
(2 2 4 4)
(let [*modulus* 3] (take 3 (iterate #(-> % (inc) (mod *modulus*)) 1)))
(1 2 0)
(apply (fn [x y z & args] [x y z]) (iterate inc 0))
[0 1 2]
(let [coll (take 10 (iterate inc 1))] (/ (apply + coll) (count coll)))
11/2
(let [[hd & tl] (map #(doto % prn) (iterate inc 1))] hd)
1
"1\n2\n"
(def x (map #(do (dotimes [i 100000000] (inc %)) %) (range 10)))
#'user/x
(clojure.walk/postwalk #(if (number? %) (inc %) %) {:a 5, :b {:c 3}})
{:a 6, :b {:c 4}}
(update-in {:a {:b [11 22 33 {:X 4}]}} [:a :b 3 :X] inc)
{:a {:b [11 22 33 {:X 5}]}}
(defn true-times [n] (let [state (atom 0)] (fn [] (<= (swap! state inc) n))))
#'user/true-times
(let [m {:foo 42, :bar 23}] (zipmap (keys m) (map inc (vals m))))
{:bar 24, :foo 43}
(reduce (partial apply update-in) {:a 1, :b 2} [[[:a] inc] [[:b] + 3]])
{:a 2, :b 5}
(for [[i x] (map vector [:foo :bar :baz] (iterate inc 0))] [i x])
([:foo 0] [:bar 1] [:baz 2])
(defn foo™ "Do stuff to bar. Copyright (c) 2011 jcromartie." [bar] (inc bar))
#'user/foo™
(let [a (atom 0) b (seque 5 (repeatedly #(swap! a inc)))] @a)
0
(into {} (map (juxt key (comp inc val)) {:a 1, :b 2, :c 3}))
{:a 2, :b 3, :c 4}
(->> [0 1 2] (mapv inc) (#(reduce conj % [11 12 13])))
[1 2 3 11 12 13]