1.3.0 permalink Arrow_down_16x16

concat

clojure.core

  • (concat)
  • (concat x)
  • (concat x y)
  • (concat x y & zs)
Returns a lazy seq representing the concatenation of the elements in the supplied colls.

2 Examples top

  • user=> (concat [1 2] [3 4])
    (1 2 3 4)
    
    user=> (into [] (concat [1 2] [3 4]))
    [1 2 3 4]
    
    user=> (concat [:a :b] nil [1 [2 3] 4])
    (:a :b 1 [2 3] 4)
    
    => (concat [1] [2] '(3 4) [5 6 7] #{9 10 8})
    (1 2 3 4 5 6 7 8 9 10)
    
  • user=> (concat "abc" "def")
    (\a \b \c \d \e \f)
    
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/into

    Returns a new coll consisting of to-coll with all of the items of f

  • 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:653 top

(defn concat
  "Returns a lazy seq representing the concatenation of the elements in the supplied colls."
  {:added "1.0"
   :static true}
  ([] (lazy-seq nil))
  ([x] (lazy-seq x))
  ([x y]
    (lazy-seq
      (let [s (seq x)]
        (if s
          (if (chunked-seq? s)
            (chunk-cons (chunk-first s) (concat (chunk-rest s) y))
            (cons (first s) (concat (rest s) y)))
          y))))
  ([x y & zs]
     (let [cat (fn cat [xys zs]
                 (lazy-seq
                   (let [xys (seq xys)]
                     (if xys
                       (if (chunked-seq? xys)
                         (chunk-cons (chunk-first xys)
                                     (cat (chunk-rest xys) zs))
                         (cons (first xys) (cat (rest xys) zs)))
                       (when zs
                         (cat (first zs) (next zs)))))))]
       (cat (concat x y) zs))))
Vars in clojure.core/concat:
Used in 0 other vars

Comments top

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