(let [v [1 2 3]] (let [vv []] (map #(conj vv %) v)))
([1] [2] [3])
(let [v '(1 2 3 4)] (conj (pop v) (inc (peek v))))
(2 2 3 4)
((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 3)
(3 2 1)
(let [x (vec (range 32)) y (conj x 1)] (identical? x (pop y)))
false
(reduce #(for [x % y %2] (conj x y)) [[]] [#{1}])
([1])
(reductions (fn [res x] (conj res x)) [] [1 2 3 4 5])
([] [1] [1 2] [1 2 3] [1 2 3 4] [1 2 3 4 5])
(defn null-string [buf len] (reduce #(conj %1 (.getByte buf)) [] (range len)))
#'user/null-string
(map (fn [row] (conj row ["6" "7"])) [["1" "2" "3"] ["4" "5"]])
(["1" "2" "3" ["6" "7"]] ["4" "5" ["6" "7"]])
(let [[first_12 & rest_85] (list 1 2 3)] (conj (vec rest_85) first_12))
[2 3 1]
(reduce #(conj % (first %2) (second %2)) [] {:a 1, :b 2})
[:a 1 :b 2]
(apply merge-with (comp flatten (partial conj [])) [{:hello 1} {:hello 3} {:hello 4}])
{:hello (1 3 4)}
(= (count (reduce conj (hash-map) (for [i (range 30)] [i nil]))) 30)
true
(= '(1 2 3 4) (conj '(2 3 4) 1))
true
(defmacro m [y & b] `(binding [x (conj x ~y)] ~@b))
#'user/m
(defn otherfn [a b c & args] (println (conj args c b a)))
#'user/otherfn
(reduce #(conj %1 (+ (last %1) %2)) [1] '(2 3 4))
[1 3 6 10]
(reduce #(conj %1 (+ (last %1) %2)) [1] [2 3 4 5])
[1 3 6 10 15]
(update-in [1 2 [[3 4 5]]] [2] (comp #(conj % 6) first))
[1 2 [3 4 5 6]]
(map #(conj % 1) (partition 3 [0 0 0 1 1 1]))
((1 0 0 0) (1 1 1 1))
(swap! (atom {:numbers #{0}}) update-in [:blubber] (fnil conj #{}) 1 2 3)
{:blubber #{1 2 3}, :numbers #{0}}
(->> [0 1 2] (mapv inc) (#(reduce conj % [11 12 13])))
[1 2 3 11 12 13]
(reduce (fn [[results chunk] item] (if (= item (peek chunk) :c) [(conj results (pop chunk)) []] [results (conj chunk item)])) [[] []] [:a :b :c :c :d :e :c :c :f])
[[[:a :b] [:d :e]] [:f]]
(reduce (fn [[runs run] v] (if (= v (peek run)) [runs (conj run v)] [(conj runs run) []])) [[] []] [:a :a :b :b :b :b :c :c :a :d :d])
[[[] [] [] [] [] [] [] [] [] [] []] []]
(reduce (fn [v [i x]] (conj (reduce (fn [v _] (conj v nil)) v (range (- i (count v) 1))) x)) [] '((1 "foo") (2 "bar") (4 "moose")))
["foo" "bar" nil "moose"]
(defn distinct-by' [f coll] (peek (reduce (fn [[found results] e] (let [index (f e)] (if (contains? found index) [found results] [(conj found index) (conj results e)]))) [#{} []] coll)))
#'user/distinct-by'
(map #(reductions conj [] %) (take-while seq (iterate rest [1 2 3 4])))
(([] [1] [1 2] [1 2 3] [1 2 3 4]) ([] [2] [2 3] [2 3 4]) ([] [3] [3 4]) ([] [4]))
(let [L (with-meta (seq '(a b)) {:foo :bar})] (meta (conj L 'c)))
{:foo :bar}
(reduce conj [] (map val (sort {0 :a, 1 :b, 2 :c, 3 :d})))
[:a :b :c :d]
(apply merge-with conj {:a [], :b []} [{:a 1} {:b 2, :a 2} {:b 2}])
{:a [1 2], :b [2 2]}
(let [init [1 2 3] v2 (conj init 4)] {:states [init v2]})
{:states [[1 2 3] [1 2 3 4]]}
(defmulti new (fn [& args] (vec (conj (map class (rest args)) (first args)))))
#'user/new
(conj {:a 1, :b 2} {:c 3, :d 4} {:e 5, :f 6})
{:a 1, :b 2, :c 3, :d 4, :e 5, :f 6}
(conj {:a 1, :c 3} (when false [:b 2]) (when true [:d 4]))
{:a 1, :c 3, :d 4}
(-> (list 1) (with-meta {:x 1}) (conj 2) (with-meta {:y 2}) next meta)
{:x 1}
(reduce #(update-in %1 [(first %2)] conj (second %2)) {} [[:a 1] [:a 2]])
{:a (2 1)}
(let [v [[1 2] [3 4]]] (update-in v [(dec (count v))] conj 5))
[[1 2] [3 4 5]]
(reduce (fn [[found dups] e] (if (contains? found e) [found (conj dups e)] [(conj found e) dups])) [#{} #{}] [0 1 2 1 2 1 3 4])
[#{0 1 2 3 4} #{1 2}]
(conj [{:a 1, :b 2} {:a 2, :b 3}] [{:a 2, :b 4}])
[{:a 1, :b 2} {:a 2, :b 3} [{:a 2, :b 4}]]
(transduce cat conj '((1 2 3) (4 5 6) (7 8 9)))
[1 2 3 4 5 6 7 8 9]
((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5)
(5 4 3 2 1)
(defn fibs ([] (fibs [1 1])) ([so-far] (conj so-far (apply + (take-last 2 so-far)))))
#'user/fibs
(reduce (fn [[i v] x] [(inc i) (conj v x)]) [0 []] (range 5))
[5 [0 1 2 3 4]]
(map #(conj %2 %1) (iterate inc 0) (partition 2 1 [:end] "test"))
((0 \t \e) (1 \e \s) (2 \s \t) (3 \t :end))
(reduce (fn [[runs run] v] (if (= v (peek run)) [runs (conj run v)] [(conj runs run) [v]])) [[] []] [:a :a :b :b :b :b :c :c :a :d :d])
[[[] [:a :a] [:b :b :b :b] [:c :c] [:a]] [:d :d]]
((comp (juxt :accum :result) reduce) (fn [{:keys [accum result]} x] {:accum (conj accum x), :result (conj result (accum x))}) {:accum #{}, :result []} [:a :b :b :c :d :c])
[#{:a :b :c :d} [nil nil :b nil nil :c]]
(apply into (reduce (fn [[results chunk] item] (if (= item (peek chunk) :c) [(conj results (pop chunk)) []] [results (conj chunk item)])) [[] []] [:a :b :c :c :d :e :c :c :f]))
[[:a :b] [:d :e] :f]
(reduce #(update-in %1 [(first %2)] (fnil conj []) (second %2)) {} [[:a 1] [:a 2]])
{:a [1 2]}
(apply conj {} (map #(vector % (str % "_val")) '(a b c d)))
{a "a_val", b "b_val", c "c_val", d "d_val"}
(conj {[1 1] [0 1], [1 2] [1 3]} {[1 1] [1 0]})
{[1 1] [1 0], [1 2] [1 3]}
(let [foo #(partial conj (empty %))] ((foo [1 2 3]) 4 5 6))
[4 5 6]