You're viewing version 1.2.0 of concat. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16



  • (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

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

  • 0

    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:592 top

(defn concat
  "Returns a lazy seq representing the concatenation of the elements in the supplied colls."
  {:added "1.0"}
  ([] (lazy-seq nil))
  ([x] (lazy-seq x))
  ([x y]
      (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)))
  ([x y & zs]
     (let [cat (fn cat [xys zs]
                   (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))))
Used in 416 other vars (expand)
booleans longs shorts bound-fn time if-not letfn for dosync with-open sync let dotimes defmethod lazy-cat defstruct with-in-str loop import defrecord with-out-str floats ->> refer-clojure .. with-loading-context future doubles doto proxy-super assert memfn chars when-first mapcat definline pvalues ns with-precision proxy-name or condp with-local-vars with-bindings when-let cycle interleave amap -> while case ints deftype bytes partial if-let and declare locking partition definterface delay defmulti proxy reify defonce io! areduce binding doc emit-array-impls with-sh-dir with-sh-env with-bindings formatter-out formatter pp with-pprint-dispatch pprint-logical-block source dir do-template deftest- assert-predicate deftest is testing try-expr assert-any are with-test-out set-test with-test with-junit-output with-tap-output append-child deftype capture-and-send with-command-line cond-let raise handler-case defn-memo defhinted defalias defnk cell ?- <- compute-sip preduce trace-datalog build-atom with-in-reader with-out-append-writer with-out-writer deferror throw-msg continue continue-with with-handler do-not-handle raise re-case case in-case instance-case find-ns-decls-on-classpath source run defadt defmethod* lazy-walk import-static with-in-reader with-out-append-writer with-out-writer with-system-properties with-connection formatter-out primes info log trace error spy with-logs warn enabled? debug fatal macrolet deftemplate defsymbolmacro with-symbol-macros symbol-macrolet with-direct-linking letfn- lazy-get vars times dir has-args expect docs with-monad domonad defmonad m-when-not m-when monad monad-transformer defmonadfn formatter prlabel pp with-pprint-dispatch pprint-logical-block defstream with-profile-data profile prof with-system-properties rec-seq rec-cat rec-seq rec-cat with-sh-dir with-sh-env with-sh-dir with-sh-env update-values with-query-results transaction with-connection create-table docodepoints dochars partial deftype- defst docodepoints dochars << do-swing do-swing-and-wait deftest- do-template assert-predicate deftest is testing try-expr assert-any are with-test-out set-test with-test dotrace deftrace match with-ns with-temp-ns defservice time-series-plot box-plot add-box-plot add-categories stacked-bar-chart bar-chart heat-map xy-plot pie-chart scatter-plot dynamic-scatter-plot conj-cols line-chart function-plot add-points histogram sliders add-function add-lines stacked-area-chart area-chart dynamic-xy-plot add-histogram $rollup combine-with conj-rows $fn with-data transform-with LINE with-rotation sketch with-translation deriv-fn deriv reset define-ant-task has-run? define-ant-type deftarget define-all-ant-tasks checkout-deps-paths find-lib-jars get-classpath get-jvm-args compile defproject get-repository-list repl-server form-for-testing-namespaces describe testing-fn for-these it should defconfig describe expand-subcontext-forms defn! times has-args expect fail for-these collection-generator char-generator for-all generator report-lines context-lines testing-fn it with-timing rewrite-=> debug-repl local-bindings should given and when then wtf with-re-defn namespaces-to-test local-bindings eval-with-locals append strict-mode before transform-content deftemplate snippet* defsnippets template defsnippet prepend transformation at clone-for sniptest let-select snippet lockstep-transformation swank macroexpand-all* defslimefn eval-for-emacs with-emacs-package send-repl-results-to-emacs sldb-loop dothread-keeping-clj break source-location-for-frame with-env-locals failing-gracefully continuously find-definitions-for-emacs dothread-keeping one-of? connection-info local-bindings returning keep-bindings compile-string-for-emacs dothread dothread-swank dispatch-event with-package-tracking potential-static potential-completions scan-paths with-timeout defhook with-connection inspect-meta-information label-value-line* with-swank-io delete-file-recursive all-files-in-directory start-repl call-being-tested expect fake with-default-identity memfn-varargs with-connection when-feature with-default-session-options with-ssh-agent defcontract with-constraints defconstrainedfn expand-and-quote default-obj-tester combine-testers extend-tester toggle-button button-group radio-button radio-button-menu-item auto-setters general-button add-action-listener button icon-setters *button-known-keys* check-box check-box-menu-item insert-at combo-box add-listener drop-nth label split-vertical shelf set-constraint! general-panel split-horizontal jlist stack text-field frame list-model tree panel scroll-panel add-list-selection-listener expect has-args times contract provide-contracts

Comments top

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