(for [[x n] (map vector [:a :b :c] (iterate inc 0))] (println x n))
(nil nil nil)
":a 0\n:b 1\n:c 2\n"
(reduce #(map %2 %1) [1 2 3] [inc #(* 2 %) dec])
(3 5 7)
(def triangle-nums (map #(/ (* % (+ % 1)) 2) (iterate inc 1)))
#'user/triangle-nums
(reduce #(update-in %1 [%2] (fnil inc 0)) {} [1 2 3 1 2 1])
{1 3, 2 2, 3 1}
(reduce-kv (fn [m k v] (assoc m k (inc v))) {} {:a 1, :b 10})
{:a 2, :b 11}
(for [a (range 2) :let [b (inc a)] c (range b)] [a b c])
([0 1 0] [1 2 0] [1 2 1])
(let [v [1 2 3]] (= (take (count v) (iterate inc (first v))) v))
true
(letfn [(odd-args [& xs] (filter odd? xs))] (take 5 (apply odd-args (iterate inc 0))))
(1 3 5 7 9)
(into {} (map (fn [[k v]] [k (inc v)]) {:a 0, :b 1, :c 2}))
{:a 1, :b 2, :c 3}
(reduce (fn [v x] (conj v (inc x))) [] (list 1 2 3 4 5))
[2 3 4 5 6]
(def yolo (take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1)))
#'user/yolo
((fn [fns coll] (map #(map % coll) fns)) [dec identity inc] [3 4])
((2 3) (3 4) (4 5))
(#(into {} (map (juxt key (comp %1 val)) %2)) inc {1 2, 3 4})
{1 3, 3 5}
(reduce #(update-in %1 [%2] (fnil inc 0)) {:a 1, :b 4} [:b :c])
{:a 1, :b 5, :c 1}
(for [x [1 2 3] :let [y [(inc x) (dec x)]] result y] result)
(2 0 3 1 4 2)
(first (last (take 5 (iterate (fn [[arr n]] [(conj arr n) (inc n)]) [[] 0]))))
[0 1 2 3]
(defn ranger [a b] (if (< a b) (into [a] (ranger (inc a) b)) []))
#'user/ranger
(for [a (range 2) b (range (inc a)) c (range b)] [a b c])
([1 1 0])
(defn vec-remove [vector position] (vec (concat (subvec vector 0 position) (subvec vector (inc position)))))
#'user/vec-remove
(update-in {:a [1 2 3]} [:a] (fn [x] (conj (pop x) (inc (peek x)))))
{:a [1 2 4]}
(let [[foo bar baz] (map #(% %2) [identity inc identity] [1 2 3])])
nil
((fn [x] (map #(take % x) (range 1 (inc (count x))))) [1 2 3])
((1) (1 2) (1 2 3))
(let [x (iterate inc 0)] (take 10 (concat (take 3 x) [-1] (drop 3 x))))
(0 1 2 -1 3 4 5 6 7 8)
(let [a (atom nil)] (reset! a (lazy-seq (cons 1 (map inc @a)))) (take 4 @a))
(1 2 3 4)
(def x (map #(do (dotimes [i 100000000] (inc %)) (println %) %) (range 10)))
#'user/x
(let [m {:first 31, :second 63, :third 127}] (zipmap (keys m) (map inc (vals m))))
{:first 32, :second 64, :third 128}
(loop [i 1] (if (<= i 12) (do (print i " ") (recur (inc i)))))
nil
"1 2 3 4 5 6 7 8 9 10 11 12 "
(clojure.walk/prewalk #(if (number? %) (inc %) %) [[1 2 3] '(1 2 3)])
[[2 3 4] (2 3 4)]
(into [] (map #(update-in % [:a] inc) [{:a 1, :b 2} {:a 3, :b 4}]))
[{:a 2, :b 2} {:a 4, :b 4}]
(let [coll (range 4)] (do (pr coll) (print " ") (map inc coll) (pr coll)))
nil
"(0 1 2 3) (0 1 2 3)"
(let [v [1 2 3]] (reduce #(update-in %1 [%2] inc) v (range (count v))))
[2 3 4]
(let [foo {:a 1, :b 2, :c 3}] (zipmap (keys foo) (map inc (vals foo))))
{:a 2, :b 3, :c 4}
((fn add [x y] (if (zero? x) y (recur (dec x) (inc y)))) 5 10)
15
(let [m {:a 1, :b 2}] (into {} (map (fn [[k v]] [k (inc v)]) m)))
{:a 2, :b 3}
(let [r (:repeat {:repeat 5} 0)] (if (< r 2) [r] (range 1 (inc r))))
(1 2 3 4 5)
(map (comp inc (partial rem 3)) [1 2 3 4 5 6 7 8 9])
(1 2 1 4 4 4 4 4 4)
(doseq [[name index] (map vector [:a :b :c] (iterate inc 0))] (prn (str index name)))
nil
"\"0:a\"\n\"1:b\"\n\"2:c\"\n"
(update-in {:foo {:bar {:baz [1 2 3 4]}}} [:foo :bar :baz] #(map inc %))
{:foo {:bar {:baz (2 3 4 5)}}}
(let [x (atom 1) _ (do (swap! x inc) (swap! x * 2))] @x)
4
(re-find #"^\((inc|dec|identity) (.+?)\)(\s*;.*)?$" "(inc hyPiRion) ; I guess :)")
["(inc hyPiRion) ; I guess :)" "inc" "hyPiRion" " ; I guess :)"]
(defn run-indexed! [f coll] (reduce (fn [i x] (f i x) (inc i)) 0 coll))
#'user/run-indexed!
(loop [b (int 0)] (let [c (loop [a 1] a)] (if false (recur (inc c)))))
nil
(loop [foo 0 r []] (if (= foo 5) r (recur (inc foo) (conj r foo))))
[0 1 2 3 4]
(->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (apply +))
11
(defn zagzig [n] (take n (apply mapcat list ((juxt reverse identity) (range 1 (inc n))))))
#'user/zagzig
(loop [x 0 xs []] (if (< x 10) (recur (inc x) (conj xs x)) xs))
[0 1 2 3 4 5 6 7 8 9]
(let [x (iterate #(do (print "test") (inc %1)) 1)] (rest x) (first x))
1
(into {} (map (fn [k v] (vector k v)) [:a :b :c] (iterate inc 0)))
{:a 0, :b 1, :c 2}
(let [n 2 x (range 5)] (concat (take n x) (drop (inc n) x)))
(0 1 3 4)
(map #(inc (* (dec %) (/ (* 6 %) 2))) (range 1 20))
(1 7 19 37 61 91 127 169 217 271 331 397 469 547 631 721 817 919 1027)