(let [L (with-meta '(a b) {:foo :bar})] (meta (conj L 'c)))
{:foo :bar}
(reduce conj '([1 2 3] [4 5 6] [7 8 9]))
[1 2 3 [4 5 6] [7 8 9]]
(update-in {:value 'foo, :children []} [:children] (fn [c] (conj c {:value 'bar, :children []})))
{:children [{:children [], :value bar}], :value foo}
(map (juxt count class) (reductions conj {} (map vec (partition 2 (range 20)))))
([0 clojure.lang.PersistentArrayMap] [1 clojure.lang.PersistentArrayMap] [2 clojure.lang.PersistentArrayMap] [3 clojure.lang.PersistentArrayMap] [4 clojure.lang.PersistentArrayMap] [5 clojure.lang.PersistentArrayMap] [6 clojure.lang.PersistentArrayMap] [7 clojure.lang.PersistentArrayMap] [8 clojure.lang.PersistentArrayMap] [9 clojure.lang.PersistentHashMap] [10 clojure.lang.PersistentHashMap])
((fn [x] (conj (butlast x) (last x))) '(a b c d))
(d a b c)
(defn invoke-with-ctx [ctx & fns] (reduce #(conj %1 (%2 ctx)) [] fns))
#'user/invoke-with-ctx
(reduce conj {} (map vec (partition 2 [:a 1 :b 2 :c 3])))
{:a 1, :b 2, :c 3}
(let [start '(1 2 3)] (identical? start (pop (conj start 4))))
true
(let [m {:foo [1]}] (assoc m :foo (conj (get m :foo) 2)))
{:foo [1 2]}
(reductions (fn [a b] (conj a b)) #{} [1 2 3 4])
(#{} #{1} #{1 2} #{1 2 3} #{1 2 3 4})
(map (juxt count class) (reduce conj {} (map vec (partition 2 (range 20)))))
([2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry] [2 clojure.lang.MapEntry])
(map #(conj % :e) [[1 2 3 4] [2 3 4]])
([1 2 3 4 :e] [2 3 4 :e])
(reduce (fn ([] nil) ([a b] (conj a (first b)))) [] [[1] [2] [3]])
[1 2 3]
(reduce #(conj %1 (str %2 "=") %2) [] '(a b c))
["a=" a "b=" b "c=" c]
(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))
{:a #{"a" "b"}}
(reduce conj (map (fn [[key val]] {val key}) {:foo "bar", :baz "qux"}))
{"bar" :foo, "qux" :baz}
(let [a [] b (conj a 1) onedex (dec (count b))] [b onedex])
[[1] 0]
(reduce #(conj %1 [(keyword (name (key %2))) (val %2)]) {} (ns-map *ns*))
{:doseq #'clojure.core/doseq, :unsigned-bit-shift-right #'clojure.core/unsigned-bit-shift-right, :neg? #'clojure.core/neg?, :var-set #'clojure.core/var-set, :global-hierarchy #'clojure.core/global-hierarchy, :if-not #'clojure.core/if-not, :sequential? #'clojure.core/sequential?, :*print-level* #'clojure.core/*print-level*, :shuffle #'clojure.core/shuffle, :boolean-array #'clojure.core/boolean-arra...
(loop [acc [] [e & r] [2 4 6 7 8 10]] (if (odd? e) (into (conj acc (inc e)) r) (recur (conj acc e) r)))
[2 4 6 8 8 10]
(let [p 5 in (shuffle (range 10))] (reduce (fn [[l g] i] (if (< i p) [(conj l i) g] [l (conj g i)])) [[] []] in))
[[2 0 4 1 3] [9 7 6 8 5]]
(:foo (meta (conj (with-meta (seq '(1 2 3)) {:foo "bar"}) 4)))
"bar"
(map (fn [row] (conj row "6" "7")) [["1" "2" "3"] ["4" "5"]])
(["1" "2" "3" "6" "7"] ["4" "5" "6" "7"])
(conj [] (loop [i 5] (if (pos? i) (recur (- i 2)) i)))
[-1]
(= [1 '?x 3] '[1 ?x 3] (conj [1 '?x] 3))
true
(defmacro script [docstr & body] `(if *dispatch* ~(conj body 'do)))
#'user/script
(update-in {:a 1, :b {:c [1 2 3]}} [:b :c] conj 4)
{:a 1, :b {:c [1 2 3 4]}}
(map #(conj % 10) [[1 2 3] '(1 2 3)])
([1 2 3 10] (10 1 2 3))
(for [c [[1 2 3] '(1 2 3)]] (conj c 4))
([1 2 3 4] (4 1 2 3))
(defn foo [x] (when (> x 0) (conj (foo (dec x)) x)))
#'user/foo
(reduce conj '() [9 8 7 6 5 4 3 2 1])
(1 2 3 4 5 6 7 8 9)
(let [x '(1 2 3)] [(cons 0 x) (conj x 0)])
[(0 1 2 3) (0 1 2 3)]
(let [a (atom {:x #{1}})] (swap! a update-in [:x] conj 2))
{:x #{1 2}}
(let [in [{:check ["foo"]} {:check ["bar"]}]] (apply merge-with (partial apply conj) in))
{:check ["foo" "bar"]}
(for [coll [[1 2 3] '(1 2 3)]] (conj coll 4))
([1 2 3 4] (4 1 2 3))
(let [v [1 2 3 4]] (conj (pop v) (inc (peek v))))
[1 2 3 5]
(map #(apply + %) (rest (reductions conj [] [1 2 3 4])))
(1 3 6 10)
(defmacro m [y & b] `(let [~'x (conj ~'x ~y)] ~@b))
#'user/m
((fn [[x & xs]] (reductions conj [x] xs)) [1 2 3 4])
([1] [1 2] [1 2 3] [1 2 3 4])
(let [vec [2 3 4 5]] (conj (pop vec) (inc (peek vec))))
[2 3 4 6]
(cond-> #{1 2 3} (= (+ 1 2) 3) (conj 4))
#{1 2 3 4}
(map (fn update-deepest-vector [e v] (if (vector? (peek v)) (conj (pop v) (update-deepest-vector e (peek v))) (conj v e))) (range) [[0 1] [0 [1]] [0 [[1]]]])
([0 1 0] [0 [1 1]] [0 [[1 2]]])
(loop [i 3 a []] (if (zero? i) a (recur (dec i) (conj a (loop [j 3 b []] (if (zero? j) b (recur (dec j) (conj b [i j]))))))))
[[[3 3] [3 2] [3 1]] [[2 3] [2 2] [2 1]] [[1 3] [1 2] [1 1]]]
(#(apply hash-map (conj (into [] (interpose %1 %2)) %1)) 0 [:a :b :c])
{:a 0, :b 0, :c 0}
(reduce #(conj %1 (+ (or (last %1) 0) %2)) [] [3 11 8])
[3 14 22]
(conj '[(1 2) (3 4)] (take 2 '(5 6 7 8)))
[(1 2) (3 4) (5 6)]
(reduce conj #{} [:a :b :c :d :a :b :c :a :b :a])
#{:a :b :c :d}
(reduce #(conj %1 %2) '(0) '(1 2 3 4 5))
(5 4 3 2 1 0)
(merge-with (fnil conj [] []) {:a [1], :b [1 2]} {:b [3 4], :c [1]})
{:a [1], :b [1 2 [3 4]], :c [1]}
(do (def dbg (atom nil)) (dotimes [i 10] (swap! dbg conj i)) @dbg)
(9 8 7 6 5 4 3 2 1 0)
(conj (vec (drop-last [1 2 3 4])) (inc (last [1 2 3 4])))
[1 2 3 5]