Abstract around NonEmptyList<A>
, which is similar to a Cons-style list, but must contain
at least one element (cannot be empty).
Static methods
staticappend(this:NonEmptyList<A>, nel:Nel<A>):Nel<A>
Appends another non-empty list to this Nel<A>
.
Warning: this operation is O(n)
staticflatMap<B>(this:NonEmptyList<A>, f:A ‑> Nel<B>):Nel<B>
staticfromArray<A>(arr:ReadonlyArray<A>):Option<Nel<A>>
staticinit(this:NonEmptyList<A>):ReadonlyArray<A>
Gets the initial elements (all but the last element) of the Nel<A>
as a possibly-empty ReadonlyArray<A>
Warning: this operation is O(n)
staticlast(this:NonEmptyList<A>):A
Gets the last item of the Nel<A>
, which is guaranteed to exist.
Warning: this operation is O(n)
staticmap<B>(this:NonEmptyList<A>, f:A ‑> B):Nel<B>
staticpop(this:NonEmptyList<A>):Tuple<A, ReadonlyArray<A>>
staticpush(this:NonEmptyList<A>, a:A):Nel<A>
staticshift(this:NonEmptyList<A>):Tuple<A, ReadonlyArray<A>>
statictail(this:NonEmptyList<A>):ReadonlyArray<A>
Gets the tail (all but the first element) of the Nel<A>
as a possibly-empty ReadonlyArray<A>
statictoArray(this:NonEmptyList<A>):ReadonlyArray<A>
Converts the Nel<A>
to a ReadonlyArray<A>
Warning: this operation is O(n)