• (into to from)
Returns a new coll consisting of to-coll with all of the items of
from-coll conjoined.

4 Examples top

  • ; Maps can be constructed from a sequence of 2-vectors or a sequence 
    ; of maps
    user=> (into (sorted-map) [ [:a 1] [:c 3] [:b 2] ] )
    {:a 1, :b 2, :c 3}
    user=> (into (sorted-map) [ {:a 1} {:c 3} {:b 2} ] )
    {:a 1, :b 2, :c 3}
    
    ; When maps are the input source, they convert into an unordered sequence 
    ; of key-value pairs, encoded as 2-vectors
    user=> (into [] {1 2, 3 4})
    [[1 2] [3 4]]
    
  • ; Items are conj'ed one at a time, which puts them at the head of 
    ; the destination list
    user=> (into () '(1 2 3))
    (3 2 1)
    
  • (defn test-key-inclusion-cols
      "return all values in column1 that arent' in column2"
      [column1 column2]
      (filter (complement (into #{} column2)) column1))
    
  • ; Change from one type of map to another
    user=> (into (sorted-map) {:b 2 :c 3 :a 1})
    {:a 1, :b 2, :c 3}
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj ni

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:5997 top

(defn into
  "Returns a new coll consisting of to-coll with all of the items of
  from-coll conjoined."
  {:added "1.0"
   :static true}
  [to from]
  (if (instance? clojure.lang.IEditableCollection to)
    (persistent! (reduce conj! (transient to) from))
    (reduce conj to from)))
Vars in clojure.core/into:
Used in 0 other vars

Comments top

No comments for into. Log in to add a comment.