(reduce #(conj %1 %2) #{} [1 2 3 4 4 4 3 3])
#{1 2 3 4}
(reduce (fn [result element] (if (< element 10) (conj result element) result)) [] (range 20))
[0 1 2 3 4 5 6 7 8 9]
(defn update-top [stack f & args] (conj (pop stack) (apply f (peek stack) args)))
#'user/update-top
(= (quote (:a :b :c :d :e)) (conj (quote (:a :b :c :d)) :e))
false
(reduce #(if (< (reduce + %1) 8) (conj %1 %2) %1) [] (range 20))
[0 1 2 3 4]
(defn otherfn [a b c & args] (apply println (conj args c b a)))
#'user/otherfn
(mapcat #(rest (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])
(count @(let [queue (atom [])] (dotimes [n 3000] (swap! queue conj n)) queue))
3000
(conj {:a 1, :b 2} {:a 3, :d 4} {:a 5, :f 6})
{:a 5, :b 2, :d 4, :f 6}
(reduce (fn [s b] (conj s [(second (first s)) b])) '() (range 6))
([4 5] [3 4] [2 3] [1 2] [0 1] [nil 0])
(reduce #(conj %1 (vector (* 2 %2))) [] [1 2 3 4 5])
[[2] [4] [6] [8] [10]]
(conj {} {:a 1, :b 2} {:a 3, :d 4} {:a 5, :f 6})
{:a 5, :b 2, :d 4, :f 6}
(reduce #(merge-with (partial conj []) %1 %2) [{:A 1} {:B 3} {:B 4}])
{:A 1, :B [3 4]}
(apply conj {} (map (fn [[k v]] [(name k) v]) {:k1 "k2", :v3 "v4"}))
{"k1" "k2", "v3" "v4"}
(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}]
(let [foo [[1 2] [2 3]]] (reduce #(conj %1 (last %2)) foo))
[1 2 3]
(reduce (fn [[i acc] el] [(inc i) (conj acc el)]) [0 []] (range 10))
[10 [0 1 2 3 4 5 6 7 8 9]]
(let [v []] (do (for [item [1 2 3]] (conj v item)) (println v)))
nil
"[]\n"
(conj #{2 4 6} 1 2 3 4 5 6 7 8)
#{1 2 3 4 5 6 7 8}
(defn make-sets [& pairs] (reduce (fn [master [who what]] (update-in master [who] conj what)) {}))
#'user/make-sets
(= '(:a :b :c :d :e) (conj '(:a :b :c :d) :e))
false
(let [x [1 2 3 4]] (conj (subvec x 0 3) (subvec x 3)))
[1 2 3 [4]]
(let [z 4 a-seq [1 2 3]] (reduce #(conj %1 %2 z) [] a-seq))
[1 4 2 4 3 4]
(let [v (atom [])] (dotimes [n 100000] (swap! v conj n)) (apply max (shuffle @v)))
99999
(let [vec [0 1 2 3 4 5]] (conj (pop vec) (inc (peek vec))))
[0 1 2 3 4 6]
(reduce #(if (< (reduce + %1) 10) (conj %1 %2) %1) [] (range 20))
[0 1 2 3 4]
((fn [x & args] (reduce + (conj args x))) 3 1 2 3 4)
13
(conj nil {:a 1, :b 2} {:a 3, :d 4} {:a 5, :f 6})
({:a 5, :f 6} {:a 3, :d 4} {:a 1, :b 2})
(let [a {:a []} c [{:a 2} {:a 3}]] (apply merge-with conj a c))
{:a [2 3]}
(let [L (with-meta (map identity '(a b)) {:foo :bar})] (meta (conj L 'c)))
nil
(apply merge-with #(conj [] %1 %2) [{:a 1, :b 2} {:a 3, :b 4}])
{:a [1 3], :b [2 4]}
(reduce (fn [ranges [start end :as el]] (let [[s e] (peek ranges)] (if (> start e) (conj ranges el) (conj (pop ranges) [s end])))) [[3 3]] [[1 2] [4 5]])
[[3 2] [4 5]]
(reduce #(if (>= (apply + (last %1)) 5) (conj %1 [%2]) (update-in %1 [(dec (count %1))] (fn [coll] (conj coll %2)))) [[]] [1 3 5 2 2 1 3 3 2])
[[1 3 5] [2 2 1] [3 3] [2]]
(conj (->> (map :a [{:a 1} {:a 2}]) (filter #(= 1 %))) 2)
(2 1)
(defn ranger [a b] (if (< a b) (conj [a] (ranger (inc a) b)) []))
#'user/ranger
(transduce cat conj #{} '((1 2 3) (4 5 6) (7 8 9)))
#{1 2 3 4 5 6 7 8 9}
(merge-with #(if (string? %1) [%1 %2] (conj %1 %2)) ({:words "hello"} {:words "world"}))
nil
(#(apply hash-map (conj (into [] (interpose %1 %2)) %1)) 0 '(:a :b :c))
{:a 0, :b 0, :c 0}
(let [n [:a :b :c] r [22 33]] (butlast (interleave n (conj r nil))))
(:a 22 :b 33 :c)
(#(apply hash-map (conj (into [] (interpose %1 %2)) %1)) 0 #{:a :b :c})
{:a 0, :b 0, :c 0}
(loop [[x & xs :as c] (range 10) f [] r []] (if c (if (odd? x) (recur xs (conj f x) r) (recur xs f (conj r x))) [f r]))
[[1 3 5 7 9] [0 2 4 6 8]]
(-> (map (fn [[op key val]] `(.addFilter ~(name key) ~(op {:a 1, :b 2}) ~val)) [[:a :b :c] [:e :f :g]]) (conj '(doto (Query. "X")) (conj 'doto)))
(doto (doto (Query. "X")) (user/.addFilter "b" 1 :c) (user/.addFilter "f" nil :g))
(update-in {:company {:info {:total_files 10, :uploaders []}}} [:company :info :uploaders] conj {:uploader "name", :files 1})
{:company {:info {:total_files 10, :uploaders [{:files 1, :uploader "name"}]}}}
(update-in [:ol [:ol [:ol [:ol [:ol [:ol]]]]]] [1 1 1 1 1] conj [:li])
[:ol [:ol [:ol [:ol [:ol [:ol [:li]]]]]]]
(reduce (fn [v x] (conj v (inc x))) [] (list 1 2 3 4 5))
[2 3 4 5 6]
(merge-with conj {:x [], :y []} {:x 1} {:x 2, :y 3} {:x 3, :y 4})
{:x [1 2 3], :y [3 4]}
(map-indexed (fn [i v] (conj v i)) '([:a :b] [:c :d] [:e :f]))
([:a :b 0] [:c :d 1] [:e :f 2])
(first (last (take 5 (iterate (fn [[arr n]] [(conj arr n) (inc n)]) [[] 0]))))
[0 1 2 3]
(let [a '(1 2 3) b (conj a 2)] (identical? a (rest b)))
true
(transduce cat conj '() '((1 2 3) (4 5 6) (7 8 9)))
(9 8 7 6 5 4 3 2 1)