Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.
Note: Seq.Indexed
is a conversion function and not a class, and does
not use the new
keyword during construction.
Always returns a Seq.Keyed, if input is not keyed, expects an collection of [K, V] tuples.
Note: Seq.Keyed
is a conversion function and not a class, and does not
use the new
keyword during construction.
Always returns a Seq.Set, discarding associated indices or keys.
Note: Seq.Set
is a conversion function and not a class, and does not
use the new
keyword during construction.
True if maybeSeq
is a Seq, it is not backed by a concrete
structure such as Map, List, or Set.
Generated using TypeDoc
Seq
describes a lazy operation, allowing them to efficiently chain use of all the higher-order collection methods (such asmap
andfilter
) by not creating intermediate collections.Seq is immutable — Once a Seq is created, it cannot be changed, appended to, rearranged or otherwise modified. Instead, any mutative method called on a
Seq
will return a newSeq
.Seq is lazy —
Seq
does as little work as necessary to respond to any method call. Values are often created during iteration, including implicit iteration when reducing or converting to a concrete data structure such as aList
or JavaScriptArray
.For example, the following performs no work, because the resulting
Seq
's values are never iterated:Once the
Seq
is used, it performs only the work necessary. In this example, no intermediate arrays are ever created, filter is called three times, and map is only called once:Any collection can be converted to a lazy Seq with
Seq()
.Seq
allows for the efficient chaining of operations, allowing for the expression of logic that can otherwise be very tedious:As well as expressing logic that would otherwise seem memory or time limited, for example
Range
is a special kind of Lazy sequence.Seq is often used to provide a rich collection API to JavaScript Object.