public final class NonEmptyList<A>
extends java.lang.Object
implements java.lang.Iterable<A>
head
and tail
.Modifier and Type | Field and Description |
---|---|
A |
head
The first element of this linked list.
|
List<A> |
tail
This list without the first element.
|
Modifier and Type | Method and Description |
---|---|
NonEmptyList<A> |
append(NonEmptyList<A> as)
Appends the given list to this list.
|
<B> NonEmptyList<B> |
bind(F<A,NonEmptyList<B>> f)
Binds the given function across each element of this list with a final join.
|
NonEmptyList<A> |
cons(A a)
Prepend the given value to this list.
|
static <A> Option<NonEmptyList<A>> |
fromList(List<A> as)
Returns a potential non-empty list from the given list.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this non-empty list.
|
<B> NonEmptyList<B> |
map(F<A,B> f)
Maps the given function across this list.
|
<B> NonEmptyList<B> |
mapTails(F<NonEmptyList<A>,B> f)
Maps the given function across the tails of this list (comonad pattern).
|
static <A> F<A,NonEmptyList<A>> |
nel()
Returns a function that puts an element into a non-empty list.
|
static <A> NonEmptyList<A> |
nel(A head)
Return a non-empty list with the given value.
|
static <A> NonEmptyList<A> |
nel(A head,
List<A> tail)
Return a non-empty list with the given head and tail.
|
NonEmptyList<NonEmptyList<A>> |
sublists()
Returns a NonEmptyList of the sublists of this list.
|
NonEmptyList<NonEmptyList<A>> |
tails()
Returns a NonEmptyList of the tails of this list.
|
java.util.Collection<A> |
toCollection()
Projects an immutable collection of this non-empty list.
|
static <A> F<NonEmptyList<A>,List<A>> |
toList_()
Returns a function that takes a non-empty list to a list.
|
List<A> |
toList()
Returns a
List projection of this list. |
public final A head
public java.util.Iterator<A> iterator()
for
-each loop.iterator
in interface java.lang.Iterable<A>
public NonEmptyList<A> cons(A a)
a
- The value to prepend.public NonEmptyList<A> append(NonEmptyList<A> as)
as
- The list to append.public <B> NonEmptyList<B> map(F<A,B> f)
f
- The function to map across this list.public <B> NonEmptyList<B> bind(F<A,NonEmptyList<B>> f)
f
- The function to apply to each element of this list.public NonEmptyList<NonEmptyList<A>> sublists()
public NonEmptyList<NonEmptyList<A>> tails()
public <B> NonEmptyList<B> mapTails(F<NonEmptyList<A>,B> f)
f
- The function to map across the tails of this list.public List<A> toList()
List
projection of this list.List
projection of this list.public java.util.Collection<A> toCollection()
public static <A> F<NonEmptyList<A>,List<A>> toList_()
public static <A> NonEmptyList<A> nel(A head, List<A> tail)
head
- The first element of the new list.tail
- The remaining elements of the new list.public static <A> NonEmptyList<A> nel(A head)
head
- The value in the non-empty list.public static <A> F<A,NonEmptyList<A>> nel()
public static <A> Option<NonEmptyList<A>> fromList(List<A> as)
as
- The list to construct a potential non-empty list with.