cons package:mono-traversable
Prepend an element onto a sequence.
> 4 `cons` [1,2,3]
[4,1,2,3]
Prepend an element to a
SemiSequence, creating a non-null
SemiSequence.
Generally this uses cons underneath. cons is not efficient for most
data structures.
Alternatives:
- if you don't need to cons, use fromNullable or
nonNull if you can create your structure in one go.
- if you need to cons, you might be able to start off with an
efficient data structure such as a NonEmpty List.
fromNonEmpty will convert that to your data structure using the
structure's fromList function.
Extract the first element of a sequence and the rest of the non-null
sequence if it exists.
Use
Data.List's
: to prepend an element to a sequence.