Class List<A>
java.lang.Object
fj.data.List<A>
- All Implemented Interfaces:
Iterable<A>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA mutable, singly linked list.private static final classprivate static final classstatic final classOptic factory methods for a Liststatic final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanReturns whether or not all elements in the list are equal according to the given equality test.Appends the given list to this list.final <B> List<B> Performs function application within a list (applicative functor pattern).final A[]Returns an array from this list.static <A> List<A> arrayList(A... as) Constructs a list from the given elements.asString()A first-classasString.static StringReturns a string from the given list of characters.final <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) Binds the given function across each element of this list and the given lists with a final join.final <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) Binds the given function across each element of this list and the given lists with a final join.final <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) Binds the given function across each element of this list and the given lists with a final join.final <B,C, D, E, F$>
List<F$> Binds the given function across each element of this list and the given lists with a final join.final <B,C, D, E> List <E> Binds the given function across each element of this list and the given lists with a final join.final <B,C, D> List <D> Binds the given function across each element of this list and the given lists with a final join.final <B,C> List <C> Binds the given function across each element of this list and the given list with a final join.final <B,C> List <C> Binds the given function across each element of this list and the given list with a final join.final <B> List<B> Binds the given function across each element of this list with a final join.bind_()Provides a first-class version of bind()Returns a tuple where the first element is the longest prefix of this list that does not satisfy the given predicate and the second element is the remainder of the list.cons()Returns a function that prepends (cons) an element to a list to produce a new list.Prepends (cons) the given element to this list to product a new list.static <A> List<A> Prepends the given head element to the given tail element to produce a new list.Returns a function that prepends a value to the given list.cons_()cons_(A a) Returns a function that prepends the given value to a list.Prepends (cons) the given element to this list to product a new list.Removes the first element that equals the given object.drop(int i) Drops the given number of elements from the head of this list if they are available.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.elementIndex(Equal<A> e, A a) Returns the index of the first element in this list which is equal (by the given equality) to the query element, or None if there is no such element.final booleanPerform an equality test on this list which delegates to the .equals() method of the member instances.final booleanReturnstrueif the predicate holds for at least one of the elements of this list,falseotherwise (falsefor the empty list).Filters elements from this list by returning only elements which producetruewhen the given function is applied to them.Finds the first occurrence of an element that matches the given predicate or no value if no elements match.foldLeft()Provides a first-class version of foldLeft.final <B> BPerforms a left-fold reduction across this list.final <B> BPerforms a left-fold reduction across this list.final ATakes the first 2 elements of the list and applies the function to them, then applies the function to the result and the third element and so on.final ATakes the first 2 elements of the list and applies the function to them, then applies the function to the result and the third element and so on.final <B> BPerforms a right-fold reduction across this list.final <B> BPerforms a right-fold reduction across this list.final <B> Trampoline<B> foldRightC(F2<A, B, B> f, B b) Performs a right-fold reduction across this list in O(1) stack space.final booleanReturnstrueif the predicate holds for all of the elements of this list,falseotherwise (truefor the empty list).final UnitPerforms a side-effect for each element of this list.final voidforeachDoEffect(Effect1<A> f) Performs a side-effect for each element of this list.static <A> List<A> fromIterator(Iterator<A> it) Constructs a list from the given Iterator.A first-classfromString.fromString(String s) Returns a list of characters from the given string.Groups elements according to the given equality implementation by longest sequence of equal elements.final <B,C, D> TreeMap <B, D> groupBy(F<A, B> keyFunction, F<A, C> valueFunction, D groupingIdentity, F2<C, D, D> groupingAcc, Ord<B> keyOrd) Groups the elements of this list by a given keyFunction, applies the valueFunction and accumulates the mapped values with the given grouping accumulator function on the grouping identity.final <B,C> TreeMap <B, C> Groups the elements of this list by a given keyFunction into aTreeMapand transforms the matching elements with the given valueFunction.Groups the elements of this list by a given keyFunction into aTreeMapand transforms the matching elements with the given valueFunction.Groups the elements of this list by a given keyFunction into aTreeMap.final inthashCode()Compute the hash code from this list as a function of the hash codes of its members.abstract Ahead()The first element of the linked list or fails for the empty list.head_()First-class head function.Returns the head of the list, if any.final Aindex(int i) Returns the element at the given index if it exists, fails otherwise.init()Returns all but the last element of this list.inits()Returns the list of initial segments of this list, shortest first.Inserts the given element before the first element that is greater than or equal to it according to the given ordering.intercalate(List<List<A>> as) Intersperses this list through the given list then joins the results.intersperse(A a) Intersperses the given argument between each element of this list.final booleanisEmpty()Returnstrueif this list is empty,falseotherwise.isEmpty_()Returns a function that determines whether a given list is empty.final booleanReturnsfalseif this list is empty,trueotherwise.Returns a function that determines whether a given list is not empty.final booleanisPrefixOf(Equal<A> eq, List<A> xs) final booleanisSingle()True if and only if the list has one element.final booleanisSuffixOf(Equal<A> eq, List<A> xs) static <A> List<A> iterableList(Iterable<A> i) Takes the given iterable to a list.static <A> List<A> 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.iterator()Returns an iterator for this list.static <A> List<A> iteratorList(Iterator<A> it) Constructs a list from the given Iterator.join()A first-class version of joinstatic <A> List<A> Joins the given list of lists using a bind operation.final Alast()Returns the last element of this list.final intlength()The length of this list.length_()First-class length.Promotes the given function of arity-2 to a function on lists.static <A> List<A> list(A... as) Constructs a list from the given elements.Returns a partially applied version oflookup(Equal, List, Object).static <A,B> Option <B> Returns an associated value with the given key in the list of pairs.final <B> List<B> Maps the given function across this list.map_()Provides a first-class version of map()Maps the given function of arity-2 across this list and returns a function that applies all the resulting functions to a given argument.mapMOption(F<A, Option<B>> f) Maps the given function across this list by binding through the Option monad.final <B> Trampoline<List<B>> mapMTrampoline(F<A, Trampoline<B>> f) Maps the given function across this list by binding through the Trampoline monad.final AReturns the maximum element in this list according to the given ordering.maximumOption(Ord<A> o) Returns the maximum element in this list according to the given ordering.final AReturns the minimum element in this list according to the given ordering.minimumOption(Ord<A> o) Returns the minimum element in this list according to the given ordering.Returns a new list of all the items in this list that do not appear in the given list.final AReturns the most common element in this list.static <A> List<A> nil()Returns an empty list.nub()Removes duplicates according to object equality.Removes duplicates according to the given equality.Removes duplicates according to the given ordering.final AReturns the head of this list if there is one or the given argument if this list is empty.Returns the tail of this list if there is one or the given argument if this list is empty.partition(int n) Splits this list into lists of the given size.Partitions the list into a tuple where the first element contains the items that satisfy the the predicate f and the second element contains the items that does not.range(int from, int to) Returns a list of integers from the givenfromvalue (inclusive) to the giventovalue (exclusive).Filters elements from this list by returning only elements which producefalsewhen the given function is applied to them.static <A> List<A> replicate(int n, A a) Returns a list of the given value replicated the given number of times.reverse()Reverse this list in constant stack space.final <B> List<B> Performs a bind across each list element, but ignores the element value each time.Turn a list of functions into a function returning a list.sequenceEither(List<Either<L, B>> list) Sequence the given list and collect the output on the right side of an either.sequenceEitherLeft(List<Either<B, R>> list) Sequence the given list and collect the output on the left side of an either.sequenceEitherRight(List<Either<L, B>> list) Sequence the given list and collect the output on the right side of an either.Sequence the given list and collect the output as a function.sequenceIO(List<IO<B>> list) Sequence the given list and collect the output as an IO.sequenceList(List<List<B>> list) Sequence the given list and collect the output as an list.sequenceOption(List<Option<B>> list) Sequence the given list and collect the output as an list.sequenceP1(List<P1<B>> list) Sequence the given list and collect the output as a P1.sequenceSeq(List<Seq<B>> list) Sequence the given list and collect the output as a seq.sequenceSet(Ord<B> ord, List<Set<B>> list) Sequence the given list and collect the output as a set; use the given ord to order the set.sequenceStream(List<Stream<B>> list) Sequence the given list and collect the output as a stream.static final <B> Trampoline<List<B>> sequenceTrampoline(List<Trampoline<B>> list) Sequence the given list and collect the output as a trampoline.static final <E,B> Validation <E, List<B>> sequenceValidation(Semigroup<E> semigroup, List<Validation<E, B>> list) Sequence the given list and collect the output as a validation; use the given semigroup to reduce the errors.static <A> List<A> single(A a) Returns a list of one element containing the given value.Appends (snoc) the given element to this list to produce a new list.Sorts this list using the given order over elements using a merge sort algorithm.Returns a tuple where the first element is the longest prefix of this list that satisfies the given predicate and the second element is the remainder of the list.splitAt(int i) Splits this list into two lists at the given index.tail()The list without the first element or fails for the empty list.tail_()First-class tail function.Reutrns the tail of the list, if any.tails()Returns the list of final segments of this list, longest first.take()Provides a first-class version of take.take(int i) Takes the given number of elements from the head of this list if they are available.Returns the first elements of the head of this list that match the given predicate function.toArray()Returns a array projection of this list.Returns a array projection of this list.final Object[]final Collection<A> Projects an immutable collection of this list.Returns an either projection of this list; the given argument inLeftif empty, or the first element inRight.toStream()Returns a stream projection of this list.final StringtoString()Obtain a string representation of this list using the toString implementations of the members.traverseEither(F<A, Either<E, B>> f) Traverse through the List with given function.traverseEitherLeft(F<A, Either<B, R>> f) Traverse this list with the given function and collect the output on the left side of an either.traverseEitherRight(F<A, Either<L, B>> f) Traverse this list with the given function and collect the output on the right side of an either.Traverse this list with the given function and collect the output as a function.traverseIO(F<A, IO<B>> f) Traverse this list with the given function and collect the output as an IO.traverseList(F<A, List<B>> f) Traverse this list with the given function and collect the output as a list.traverseOption(F<A, Option<B>> f) Traverses through the List with the given functiontraverseP1(F<A, P1<B>> f) Traverse this list with the given function and collect the output as a p1.traversePromise(F<A, Promise<B>> f) traverseSeq(F<A, Seq<B>> f) Traverse this list with the given function and collect the output as a seq.traverseSet(Ord<B> ord, F<A, Set<B>> f) Traverse this list with the given function and collect the output as a set; use the given ord to order the set.traverseStream(F<A, Stream<B>> f) Traverse this list with the given function and collect the output as a stream.final <B> Trampoline<List<B>> traverseTrampoline(F<A, Trampoline<B>> f) Traverse this list with the given function and collect the output as a trampoline.traverseV2(F<A, V2<B>> f) final <E,B> Validation <E, List<B>> traverseValidation(Semigroup<E> s, F<A, Validation<E, B>> f) Traverse this list with the given function and collect the output as a validation; use the given semigroup to reduce the errors.final <B> Bstatic <A,B> List <A> Unfolds across the given function starting at the given value to produce a list.Transforms a list of pairs into a list of first components and a list of second components.zip()The first-class version of the zip function.Zips this list with the given list to produce a list of pairs.zipIndex()Zips this list with the index of its element as a pair.zipWith()Provides a first-class version of zipWithfinal <B,C> List <C> Zips this list with the given list using the given function to produce a new list.final <B,C> List <C> Zips this list with the given list using the given function to produce a new list.Methods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
List
private List()
-
-
Method Details
-
iterator
-
head
The first element of the linked list or fails for the empty list.- Returns:
- The first element of the linked list or fails for the empty list.
-
tail
-
length
public final int length()The length of this list.- Returns:
- The length of this list.
-
isEmpty
public final boolean isEmpty()Returnstrueif this list is empty,falseotherwise.- Returns:
trueif this list is empty,falseotherwise.
-
isNotEmpty
public final boolean isNotEmpty()Returnsfalseif this list is empty,trueotherwise.- Returns:
falseif this list is empty,trueotherwise.
-
uncons
-
orHead
-
orTail
-
headOption
-
toEither
-
toStream
-
toArray
-
toArrayObject
-
toArray
-
array
-
cons
-
conss
-
map
-
foreach
-
foreachDoEffect
-
filter
-
removeAll
-
delete
Removes the first element that equals the given object. To remove all matches, useremoveAll(e.eq(a))- Parameters:
a- The element to removee- AnEqualsinstance for the element's type.- Returns:
- A new list whose elements do not match the given predicate.
-
takeWhile
Returns the first elements of the head of this list that match the given predicate function.- Parameters:
f- The predicate function to apply on this list until it finds an element that does not hold, or the list is exhausted.- Returns:
- The first elements of the head of this list that match the given predicate function.
-
dropWhile
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.- Parameters:
f- The predicate function to apply through this list.- Returns:
- The list whose first element does not match the given predicate function.
-
span
Returns a tuple where the first element is the longest prefix of this list that satisfies the given predicate and the second element is the remainder of the list.- Parameters:
p- A predicate to be satisfied by a prefix of this list.- Returns:
- A tuple where the first element is the longest prefix of this list that satisfies the given predicate and the second element is the remainder of the list.
-
breakk
Returns a tuple where the first element is the longest prefix of this list that does not satisfy the given predicate and the second element is the remainder of the list.- Parameters:
p- A predicate for an element to not satisfy by a prefix of this list.- Returns:
- A tuple where the first element is the longest prefix of this list that does not satisfy the given predicate and the second element is the remainder of the list.
-
group
-
bind
-
bind
Binds the given function across each element of this list and the given list with a final join.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
bind
Binds the given function across each element of this list and the given list with a final join.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
liftM2
-
bind
Binds the given function across each element of this list and the given lists with a final join.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
bind
Binds the given function across each element of this list and the given lists with a final join.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
bind
public final <B,C, List<F$> bindD, E, F$> (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.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
bind
public final <B,C, List<G> bindD, E, F$, G> (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.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
bind
public final <B,C, List<H> bindD, E, F$, G, H> (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.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
bind
public final <B,C, List<I> bindD, E, F$, G, H, I> (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.- Parameters:
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.- Returns:
- A new list after performing the map, then final join.
-
sequence
-
sequenceEither
-
sequenceEitherLeft
-
sequenceEitherRight
Sequence the given list and collect the output on the right side of an either.- Type Parameters:
L- the type of the left valueB- the type of the right value- Parameters:
list- the given list- Returns:
- the either
-
sequenceF
-
sequenceIO
-
sequenceList
-
sequenceOption
-
sequenceP1
-
sequenceSeq
-
sequenceSet
-
sequenceStream
-
sequenceTrampoline
Sequence the given list and collect the output as a trampoline.- Type Parameters:
B- the type of the stream value- Parameters:
list- the given trampoline- Returns:
- the stream
-
sequenceValidation
public static final <E,B> Validation<E,List<B>> sequenceValidation(Semigroup<E> semigroup, List<Validation<E, B>> list) Sequence the given list and collect the output as a validation; use the given semigroup to reduce the errors.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
semigroup- the given semigrouplist- the given list- Returns:
- the validation
-
traverseEither
-
traverseEitherLeft
Traverse this list with the given function and collect the output on the left side of an either.- Type Parameters:
R- the type of the left valueB- the type of the right value- Parameters:
f- the given function- Returns:
- the either
-
traverseEitherRight
Traverse this list with the given function and collect the output on the right side of an either.- Type Parameters:
L- the type of the left valueB- the type of the right value- Parameters:
f- the given function- Returns:
- the either
-
traverseF
-
traverseIO
-
traverseList
-
traverseOption
-
traverseP1
-
traverseSeq
-
traverseSet
-
traverseStream
-
traverseTrampoline
Traverse this list with the given function and collect the output as a trampoline.- Type Parameters:
B- the type of the trampoline value- Parameters:
f- the given function- Returns:
- the trampoline
-
traversePromise
-
traverseValidation
public final <E,B> Validation<E,List<B>> traverseValidation(Semigroup<E> s, F<A, Validation<E, B>> f) Traverse this list with the given function and collect the output as a validation; use the given semigroup to reduce the errors.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
s- the given semigroupf- the given function- Returns:
- the validation
-
traverseV2
-
apply
-
append
-
foldRight
-
foldRight
Performs a right-fold reduction across this list. This function uses O(length) stack space.- Parameters:
f- The function to apply on each element of the list.b- The beginning value to start the application from.- Returns:
- The final result after the right-fold reduction.
-
foldRightC
Performs a right-fold reduction across this list in O(1) stack space.- Parameters:
f- The function to apply on each element of the list.b- The beginning value to start the application from.- Returns:
- A Trampoline containing the final result after the right-fold reduction.
-
foldLeft
Performs a left-fold reduction across this list. This function runs in constant space.- Parameters:
f- The function to apply on each element of the list.b- The beginning value to start the application from.- Returns:
- The final result after the left-fold reduction.
-
foldLeft
Performs a left-fold reduction across this list. This function runs in constant space.- Parameters:
f- The function to apply on each element of the list.b- The beginning value to start the application from.- Returns:
- The final result after the left-fold reduction.
-
foldLeft1
Takes the first 2 elements of the list and applies the function to them, then applies the function to the result and the third element and so on.- Parameters:
f- The function to apply on each element of the list.- Returns:
- The final result after the left-fold reduction.
-
foldLeft1
Takes the first 2 elements of the list and applies the function to them, then applies the function to the result and the third element and so on.- Parameters:
f- The function to apply on each element of the list.- Returns:
- The final result after the left-fold reduction.
-
reverse
-
index
Returns the element at the given index if it exists, fails otherwise.- Parameters:
i- The index at which to get the element to return.- Returns:
- The element at the given index if it exists, fails otherwise.
-
take
-
drop
-
splitAt
Splits this list into two lists at the given index. If the index goes out of bounds, then it is normalised so that this function never fails.- Parameters:
i- The index at which to split this list in two parts.- Returns:
- A pair of lists split at the given index of this list.
-
partition
Splits this list into lists of the given size. If the size of this list is not evenly divisible by the given number, the last partition will contain the remainder.- Parameters:
n- The size of the partitions into which to split this list.- Returns:
- A list of sublists of this list, of at most the given size.
-
partition
Partitions the list into a tuple where the first element contains the items that satisfy the the predicate f and the second element contains the items that does not. The relative order of the elements in the returned tuple is the same as the original list.- Parameters:
f- Predicate function.
-
inits
-
tails
-
sort
-
zipWith
Zips this list with the given list using the given function to produce a new list. If this list and the given list have different lengths, then the longer list is normalised so this function never fails.- Parameters:
bs- The list to zip this list with.f- The function to zip this list and the given list with.- Returns:
- A new list with a length the same as the shortest of this list and the given list.
-
zipWith
Zips this list with the given list using the given function to produce a new list. If this list and the given list have different lengths, then the longer list is normalised so this function never fails.- Parameters:
bs- The list to zip this list with.f- The function to zip this list and the given list with.- Returns:
- A new list with a length the same as the shortest of this list and the given list.
-
zipWith
-
zip
Zips this list with the given list to produce a list of pairs. If this list and the given list have different lengths, then the longer list is normalised so this function never fails.- Parameters:
bs- The list to zip this list with.- Returns:
- A new list with a length the same as the shortest of this list and the given list.
-
zip
-
zipIndex
-
snoc
-
forall
Returnstrueif the predicate holds for all of the elements of this list,falseotherwise (truefor the empty list).- Parameters:
f- The predicate function to test on each element of this list.- Returns:
trueif the predicate holds for all of the elements of this list,falseotherwise.
-
exists
Returnstrueif the predicate holds for at least one of the elements of this list,falseotherwise (falsefor the empty list).- Parameters:
f- The predicate function to test on the elements of this list.- Returns:
trueif the predicate holds for at least one of the elements of this list.
-
find
Finds the first occurrence of an element that matches the given predicate or no value if no elements match.- Parameters:
f- The predicate function to test on elements of this list.- Returns:
- The first occurrence of an element that matches the given predicate or no value if no elements match.
-
intersperse
-
intercalate
-
nub
-
nub
-
nub
-
head_
-
tailOption
-
tail_
-
minus
Returns a new list of all the items in this list that do not appear in the given list.- Parameters:
eq- an equality for the items of the lists.xs- a list to subtract from this list.- Returns:
- a list of all the items in this list that do not appear in the given list.
-
mapM
Maps the given function of arity-2 across this list and returns a function that applies all the resulting functions to a given argument.- Parameters:
f- A function of arity-2- Returns:
- A function that, when given an argument, applies the given function to that argument and every element in this list.
-
mapMOption
-
mapMTrampoline
Maps the given function across this list by binding through the Trampoline monad.- Parameters:
f- The function to apply through the this list.- Returns:
- A list of values in the Trampoline monad.
-
elementIndex
Returns the index of the first element in this list which is equal (by the given equality) to the query element, or None if there is no such element.- Parameters:
e- An equality for this list's elements.a- A query element.- Returns:
- The index of the first element in this list which is equal (by the given equality) to the query element, or None if there is no such element.
-
last
Returns the last element of this list. Undefined for the empty list.- Returns:
- The last element of this list or throws an error if this list is empty.
-
init
-
insertBy
Inserts the given element before the first element that is greater than or equal to it according to the given ordering.- Parameters:
f- An ordering function to compare elements.x- The element to insert.- Returns:
- A new list with the given element inserted before the first element that is greater than or equal to it according to the given ordering.
-
mode
-
groupBy
Groups the elements of this list by a given keyFunction into aTreeMap.- Parameters:
keyFunction- The function to select the keys for the map.keyOrd- An order for the keys of the tree map.- Returns:
- A TreeMap containing the keys with the accumulated list of matched elements.
-
groupBy
public final <B,C> TreeMap<B,List<C>> groupBy(F<A, B> keyFunction, F<A, C> valueFunction, Ord<B> keyOrd) Groups the elements of this list by a given keyFunction into aTreeMapand transforms the matching elements with the given valueFunction. The ordering of the keys is determined by the keyOrd parameter.- Parameters:
keyFunction- The function to select the keys for the map.valueFunction- The function to apply on each matching value.keyOrd- An order for the keys of the tree map.- Returns:
- A TreeMap containing the keys with the accumulated list of matched and mapped elements.
-
groupBy
public final <B,C> TreeMap<B,C> groupBy(F<A, B> keyFunction, F<A, C> valueFunction, Monoid<C> monoid, Ord<B> keyOrd) Groups the elements of this list by a given keyFunction into aTreeMapand transforms the matching elements with the given valueFunction. The ordering of the keys is determined by the keyOrd parameter.- Parameters:
keyFunction- The function to select the keys for the map.valueFunction- The function to apply on each matching value.monoid- A monoid, which defines the accumulator for the values and the zero value.keyOrd- An order for the keys of the tree map.- Returns:
- A TreeMap containing the keys with the accumulated list of matched and mapped elements.
-
groupBy
public final <B,C, TreeMap<B,D> D> groupBy(F<A, B> keyFunction, F<A, C> valueFunction, D groupingIdentity, F2<C, D, D> groupingAcc, Ord<B> keyOrd) Groups the elements of this list by a given keyFunction, applies the valueFunction and accumulates the mapped values with the given grouping accumulator function on the grouping identity.- Parameters:
keyFunction- The function to select the keys.valueFunction- The function to apply on each element.groupingIdentity- The identity, or start value, for the grouping.groupingAcc- The accumulator to apply on each matching value.keyOrd- An order for the keys of the tree map.- Returns:
- A TreeMap containing the keys with the accumulated result of matched and mapped elements.
-
allEqual
-
isPrefixOf
-
isSuffixOf
-
length_
-
maximum
-
maximumOption
-
minimum
-
minimumOption
-
toJavaList
-
toCollection
Projects an immutable collection of this list.- Returns:
- An immutable collection of this list.
-
list
Constructs a list from the given elements.- Parameters:
as- The elements to construct a list with.- Returns:
- A list with the given elements.
-
arrayList
Constructs a list from the given elements. -
fromIterator
-
nil
-
cons
-
cons_
-
cons
-
cons_
-
cons
-
isEmpty_
-
isNotEmpty_
-
join
-
join
-
unfold
Unfolds across the given function starting at the given value to produce a list.- Parameters:
f- The function to unfold across.b- The start value to begin the unfold.- Returns:
- A new list that is a result of unfolding until the function does not produce a value.
-
unzip
-
replicate
Returns a list of the given value replicated the given number of times.- Parameters:
n- The number of times to replicate the given value.a- The value to replicate.- Returns:
- A list of the given value replicated the given number of times.
-
range
Returns a list of integers from the givenfromvalue (inclusive) to the giventovalue (exclusive).- Parameters:
from- The minimum value for the list (inclusive).to- The maximum value for the list (exclusive).- Returns:
- A list of integers from the given
fromvalue (inclusive) to the giventovalue (exclusive).
-
fromString
Returns a list of characters from the given string. The inverse of this function isasString(List).- Parameters:
s- The string to produce the list of characters from.- Returns:
- A list of characters from the given string.
-
fromString
-
asString
Returns a string from the given list of characters. The invers of this function isfromString(String).- Parameters:
cs- The list of characters to produce the string from.- Returns:
- A string from the given list of characters.
-
asString
-
single
Returns a list of one element containing the given value.- Parameters:
a- The value for the head of the returned list.- Returns:
- A list of one element containing the given value.
-
iterateWhile
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.- Parameters:
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.- Returns:
- 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.
-
lookup
Returns an associated value with the given key in the list of pairs.- Parameters:
e- The test for equality on keys.x- The list of pairs to search.a- The key value to find the associated value of.- Returns:
- An associated value with the given key in the list of pairs.
-
lookup
Returns a partially applied version oflookup(Equal, List, Object).- Parameters:
e- The test for equality on keys.- Returns:
- A partially applied version of
lookup(Equal, List, Object).
-
bind_
-
map_
-
sequence_
Turn a list of functions into a function returning a list.- Parameters:
fs- The list of functions to sequence into a single function that returns a list.- Returns:
- A function that, when given an argument, applies all the functions in the given list to it and returns a list of the results.
-
foldLeft
-
take
-
iterableList
-
iteratorList
-
equals
Perform an equality test on this list which delegates to the .equals() method of the member instances. This is implemented with Equal.listEqual using the anyEqual rule. -
hashCode
-
toString
-
isSingle
public final boolean isSingle()True if and only if the list has one element. Runs in constant time.
-