Skip to content

clojure.core/sequence

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 6 Runnable: 1
([coll] [xform coll] [xform coll & colls])

Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. The transform should accept number-of-colls arguments

Examples

by yasuto on . May have evaluation errors.
by G1enY0ung on . May have evaluation errors.
by cljlc on . May have evaluation errors.
by phreed on . May have evaluation errors.
by green-coder on . May have evaluation errors.
by Crowbrammer on

Note by glts

Interesting background about sequence versus eduction: https://groups.google.com/d/msg/clojure/9I6MtgOTD0w/NiG5PimBCP8J

Note by divs1210

Since Clojure's implementation of sequence is in Java, and is pretty involved, I wrote a pure Clojure version to build intuition.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.