|
Copyright Workingmouse Pty. Ltd. 2007, 2008 This software is released under an open source BSD licence. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfj.data.List<A>
public abstract class List<A>
Provides an in-memory, immutable, singly linked list.
| Nested Class Summary | |
|---|---|
static class |
List.Buffer<A>
A mutable, singly linked list. |
| Method Summary | ||
|---|---|---|
List<A> |
append(List<A> as)
Appends the given list to this list. |
|
|
apply(List<F<A,B>> lf)
Performs function application within a list (applicative functor pattern). |
|
static String |
asString(List<Character> cs)
Returns a string from the given list of characters. |
|
static
|
bind_()
|
|
|
bind(F<A,List<B>> f)
Binds the given function across each element of this list with a final join. |
|
|
bind(List<B> lb,
F<A,F<B,C>> f)
Binds the given function across each element of this list and the given list with a final join. |
|
|
bind(List<B> lb,
List<C> lc,
F<A,F<B,F<C,D>>> f)
Binds the given function across each element of this list and the given lists with a final join. |
|
|
bind(List<B> lb,
List<C> lc,
List<D> ld,
F<A,F<B,F<C,F<D,E>>>> f)
Binds the given function across each element of this list and the given lists with a final join. |
|
|
bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
F<A,F<B,F<C,F<D,F<E,F$>>>>> f)
Binds the given function across each element of this list and the given lists with a final join. |
|
|
bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
List<F$> lf,
F<A,F<B,F<C,F<D,F<E,F<F$,G>>>>>> f)
Binds the given function across each element of this list and the given lists with a final join. |
|
|
bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
List<F$> lf,
List<G> lg,
F<A,F<B,F<C,F<D,F<E,F<F$,F<G,H>>>>>>> f)
Binds the given function across each element of this list and the given lists with a final join. |
|
|
bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
List<F$> lf,
List<G> lg,
List<H> lh,
F<A,F<B,F<C,F<D,F<E,F<F$,F<G,F<H,I>>>>>>>> f)
Binds the given function across each element of this list and the given lists with a final join. |
|
static
|
cons()
Returns a function that prepends (cons) an element to a list to produce a new list. |
|
List<A> |
cons(A a)
Prepends (cons) the given element to this list to product a new list. |
|
static
|
cons(A head,
List<A> tail)
Prepends the given head element to the given tail element to produce a new list. |
|
List<A> |
drop(int i)
Drops the given number of elements from the head of this list if they are available. |
|
List<A> |
dropWhile(F<A,Boolean> f)
Removes elements from the head of this list that do not match the given predicate function until an element is found that does match or the list is exhausted. |
|
boolean |
exists(F<A,Boolean> f)
Returns true if the predicate holds for at least one of the elements of this list,
false otherwise (false for the empty list). |
|
List<A> |
filter(F<A,Boolean> f)
Filters elements from this list by returning only elements which produce true when
the given function is applied to them. |
|
Option<A> |
find(F<A,Boolean> f)
Finds the first occurrence of an element that matches the given predicate or no value if no elements match. |
|
|
foldLeft(F<B,F<A,B>> f,
B b)
Performs a left-fold reduction across this list. |
|
|
foldRight(F<A,F<B,B>> f,
B b)
Performs a right-fold reduction across this list. |
|
boolean |
forall(F<A,Boolean> f)
Returns true if the predicate holds for all of the elements of this list,
false otherwise (true for the empty list). |
|
void |
foreach(Effect<A> f)
Performs a side-effect for each element of this list. |
|
Unit |
foreach(F<A,Unit> f)
Performs a side-effect for each element of this list. |
|
static List<Character> |
fromString(String s)
Returns a list of characters from the given string. |
|
abstract A |
head()
The first element of the linked list or fails for the empty list. |
|
A |
index(int i)
Returns the element at the given index if it exists, fails otherwise. |
|
List<A> |
intersperse(A a)
Intersperses the given argument between each element of this list. |
|
static
|
isEmpty_()
Returns a function that determines whether a given list is empty. |
|
boolean |
isEmpty()
Returns true if this list is empty, false otherwise. |
|
static
|
isNotEmpty_()
Returns a function that determines whether a given list is not empty. |
|
boolean |
isNotEmpty()
Returns false if this list is empty, true otherwise. |
|
static
|
iterateWhile(F<A,A> f,
F<A,Boolean> p,
A a)
Creates a list where the first item is calculated by applying the function on the third argument, the second item by applying the function on the previous result and so on. |
|
static
|
join(List<List<A>> o)
Joins the given list of lists using a bind operation. |
|
int |
length()
The length of this list. |
|
static
|
list(A... as)
Constructs a list from the given elements. |
|
|
list(B nil,
F<A,F<List<A>,B>> cons)
Performs a reduction on this list using the given arguments. |
|
static
|
map_()
|
|
|
map(F<A,B> f)
Maps the given function across this list. |
|
static
|
nil()
Returns an empty list. |
|
A |
orHead(P1<A> a)
Returns the head of this list if there is one or the given argument if this list is empty. |
|
List<A> |
orTail(P1<List<A>> as)
Returns the tail of this list if there is one or the given argument if this list is empty. |
|
static List<Integer> |
range(int from,
int to)
Returns a list of integers from the given from value (inclusive) to the given
to value (exclusive). |
|
static
|
replicate(int n,
A a)
Returns a list of the given value replicated the given number of times. |
|
List<A> |
reverse()
Reverse this list in constant stack space. |
|
|
sequence(List<B> bs)
Performs a bind across each list element, but ignores the element value each time. |
|
static
|
single(A a)
Returns a list of one element containing the given value. |
|
List<A> |
snoc(A a)
Appends (snoc) the given element to this list to produce a new list. |
|
List<A> |
sort(Ord<A> o)
Sorts this list using the given order over elements using a merge sort algorithm. |
|
P2<List<A>,List<A>> |
splitAt(int i)
Splits this list into two lists at the given index. |
|
abstract List<A> |
tail()
The list without the first element or fails for the empty list. |
|
List<A> |
take(int i)
Takes the given number of elements from the head of this list if they are available. |
|
List<A> |
takeWhile(F<A,Boolean> f)
Returns the first elements of the head of this list that match the given predicate function. |
|
Array<A> |
toArray()
Returns a array projection of this list. |
|
|
toEither(P1<X> x)
Returns an either projection of this list; the given argument in Left if empty, or
the first element in Right. |
|
Option<A> |
toOption()
Returns an option projection of this list; None if empty, or the first element in
Some. |
|
Stream<A> |
toStream()
Returns a stream projection of this list. |
|
static
|
unfold(F<B,Option<P2<A,B>>> f,
B b)
Unfolds across the given function starting at the given value to produce a list. |
|
|
zip(List<B> bs)
Zips this list with the given list to produce a list of pairs. |
|
List<P2<A,Integer>> |
zipIndex()
Zips this list with the index of its element as a pair. |
|
|
zipWith(List<B> bs,
F<A,F<B,C>> f)
Zips this list with the given list using the given function to produce a new list. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public abstract A head()
public abstract List<A> tail()
public int length()
public boolean isEmpty()
true if this list is empty, false otherwise.
true if this list is empty, false otherwise.public boolean isNotEmpty()
false if this list is empty, true otherwise.
false if this list is empty, true otherwise.
public <B> B list(B nil,
F<A,F<List<A>,B>> cons)
nil - The value to return if this list is empty.cons - The function to apply to the head and tail of this list if it is not empty.
public A orHead(P1<A> a)
a - The argument to return if this list is empty.
public List<A> orTail(P1<List<A>> as)
as - The argument to return if this list is empty.
public Option<A> toOption()
None if empty, or the first element in
Some.
public <X> Either<X,A> toEither(P1<X> x)
Left if empty, or
the first element in Right.
x - The value to return in left if this list is empty.
public Stream<A> toStream()
public Array<A> toArray()
public List<A> cons(A a)
a - The element to prepend.
public <B> List<B> map(F<A,B> f)
f - The function to map across this list.
public Unit foreach(F<A,Unit> f)
f - The side-effect to perform for the given element.
public void foreach(Effect<A> f)
f - The side-effect to perform for the given element.public List<A> filter(F<A,Boolean> f)
true when
the given function is applied to them.
f - The predicate function to filter on.
public List<A> takeWhile(F<A,Boolean> f)
f - The predicate function to apply on this list until it finds an element that does not
hold, or the list is exhausted.
public List<A> dropWhile(F<A,Boolean> f)
f - The predicate function to apply through this list.
public <B> List<B> bind(F<A,List<B>> f)
f - The function to apply to each element of this list.
public <B,C> List<C> bind(List<B> lb,
F<A,F<B,C>> f)
lb - A given list to bind the given function with.f - The function to apply to each element of this list and the given list.
public <B,C,D> List<D> bind(List<B> lb,
List<C> lc,
F<A,F<B,F<C,D>>> f)
lb - A given list to bind the given function with.lc - A given list to bind the given function with.f - The function to apply to each element of this list and the given lists.
public <B,C,D,E> List<E> bind(List<B> lb,
List<C> lc,
List<D> ld,
F<A,F<B,F<C,F<D,E>>>> f)
lb - A given list to bind the given function with.lc - A given list to bind the given function with.ld - A given list to bind the given function with.f - The function to apply to each element of this list and the given lists.
public <B,C,D,E,F$> List<F$> bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
F<A,F<B,F<C,F<D,F<E,F$>>>>> f)
lb - A given list to bind the given function with.lc - A given list to bind the given function with.ld - A given list to bind the given function with.le - A given list to bind the given function with.f - The function to apply to each element of this list and the given lists.
public <B,C,D,E,F$,G> List<G> bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
List<F$> lf,
F<A,F<B,F<C,F<D,F<E,F<F$,G>>>>>> f)
lb - A given list to bind the given function with.lc - A given list to bind the given function with.ld - A given list to bind the given function with.le - A given list to bind the given function with.lf - A given list to bind the given function with.f - The function to apply to each element of this list and the given lists.
public <B,C,D,E,F$,G,H> List<H> bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
List<F$> lf,
List<G> lg,
F<A,F<B,F<C,F<D,F<E,F<F$,F<G,H>>>>>>> f)
lb - A given list to bind the given function with.lc - A given list to bind the given function with.ld - A given list to bind the given function with.le - A given list to bind the given function with.lf - A given list to bind the given function with.lg - A given list to bind the given function with.f - The function to apply to each element of this list and the given lists.
public <B,C,D,E,F$,G,H,I> List<I> bind(List<B> lb,
List<C> lc,
List<D> ld,
List<E> le,
List<F$> lf,
List<G> lg,
List<H> lh,
F<A,F<B,F<C,F<D,F<E,F<F$,F<G,F<H,I>>>>>>>> f)
lb - A given list to bind the given function with.lc - A given list to bind the given function with.ld - A given list to bind the given function with.le - A given list to bind the given function with.lf - A given list to bind the given function with.lg - A given list to bind the given function with.lh - A given list to bind the given function with.f - The function to apply to each element of this list and the given lists.
public <B> List<B> sequence(List<B> bs)
bs - The list to apply in the final join.
public <B> List<B> apply(List<F<A,B>> lf)
lf - The list of functions to apply.
public List<A> append(List<A> as)
as - The list to append to this one.
public <B> B foldRight(F<A,F<B,B>> f,
B b)
f - The function to apply on each element of the list.b - The beginning value to start the application from.
public <B> B foldLeft(F<B,F<A,B>> f,
B b)
f - The function to apply on each element of the list.b - The beginning value to start the application from.
public List<A> reverse()
public A index(int i)
i - The index at which to get the element to return.
public List<A> take(int i)
i - The maximum number of elements to take from this list.
public List<A> drop(int i)
i - The number of elements to drop from the head of this list.
public P2<List<A>,List<A>> splitAt(int i)
i - The index at which to split this list in two parts.
public List<A> sort(Ord<A> o)
o - The order over the elements of this list.
public <B,C> List<C> zipWith(List<B> bs,
F<A,F<B,C>> f)
bs - The list to zip this list with.f - The function to zip this list and the given list with.
public <B> List<P2<A,B>> zip(List<B> bs)
bs - The list to zip this list with.
public List<P2<A,Integer>> zipIndex()
public List<A> snoc(A a)
a - The element to append to this list.
public boolean forall(F<A,Boolean> f)
true if the predicate holds for all of the elements of this list,
false otherwise (true for the empty list).
f - The predicate function to test on each element of this list.
true if the predicate holds for all of the elements of this list,
false otherwise.public boolean exists(F<A,Boolean> f)
true if the predicate holds for at least one of the elements of this list,
false otherwise (false for the empty list).
f - The predicate function to test on the elements of this list.
true if the predicate holds for at least one of the elements of this
list.public Option<A> find(F<A,Boolean> f)
f - The predicate function to test on elements of this list.
public List<A> intersperse(A a)
a - The separator to intersperse in this list.
public static <A> List<A> list(A... as)
as - The elements to construct a list with.
public static <A> List<A> nil()
public static <A> F<A,F<List<A>,List<A>>> cons()
public static <A> List<A> cons(A head,
List<A> tail)
head - The element to prepend.tail - The list to prepend to.
public static <A> F<List<A>,Boolean> isEmpty_()
public static <A> F<List<A>,Boolean> isNotEmpty_()
public static <A> List<A> join(List<List<A>> o)
o - The list of lists to join.
public static <A,B> List<A> unfold(F<B,Option<P2<A,B>>> f,
B b)
f - The function to unfold across.b - The start value to begin the unfold.
public static <A> List<A> replicate(int n,
A a)
n - The number of times to replicate the given value.a - The value to replicate.
public static List<Integer> range(int from,
int to)
from value (inclusive) to the given
to value (exclusive).
from - The minimum value for the list (inclusive).to - The maximum value for the list (exclusive).
from value (inclusive) to the given
to value (exclusive).public static List<Character> fromString(String s)
asString(List).
s - The string to produce the list of characters from.
public static String asString(List<Character> cs)
fromString(String).
cs - The list of characters to produce the string from.
public static <A> List<A> single(A a)
a - The value for the head of the returned list.
public static <A> List<A> iterateWhile(F<A,A> f,
F<A,Boolean> p,
A a)
f - The function to iterate with.p - The predicate which must be true for the next item in order to continue the iteration.a - The input to the first iteration.
public static <A,B> F<F<A,List<B>>,F<List<A>,List<B>>> bind_()
public static <A,B> F<F<A,B>,F<List<A>,List<B>>> map_()
|
Copyright Workingmouse Pty. Ltd. 2007, 2008 This software is released under an open source BSD licence. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||