FpdartOnIterable<T> extension
Get the first element of the Iterable.
If the Iterable is empty, return None.
Functional programming functions on a mutable dart Iterable using fpdart
.
- on
-
- Iterable<
T>
- Iterable<
Properties
-
firstOption
→ Option<
T> -
Get the first element of the Iterable.
If the Iterable is empty, return None.
no setter
-
head
→ Option<
T> -
Get the first element of the Iterable.
If the Iterable is empty, return None.
no setter
-
init
→ Option<
Iterable< T> > -
Return all the elements of a
Iterable
except the last one. If theIterable
is empty, return None.no setter -
lastOption
→ Option<
T> -
Get the last element of the Iterable.
If the Iterable is empty, return None.
no setter
-
tail
→ Option<
Iterable< T> > -
Return all the elements of a
Iterable
except the first one. If theIterable
is empty, return None.no setter
Methods
-
all(
bool test(T t)) → bool -
Checks whether every element of this Iterable satisfies
test
. -
ap<
B> (Iterable< B Function(T)> iterable) → Iterable<B> -
Apply all the functions inside
iterable
to this Iterable. -
append(
T element) → Iterable< T> -
Insert
element
at the end of the Iterable. -
breakI(
bool test(T t)) → (Iterable< T> , Iterable<T> ) -
Return a record where first element is longest prefix (possibly empty) of this Iterable
with elements that do not satisfy
test
and second element is the remainder of the Iterable. -
concat(
Iterable< T> other) → Iterable<T> -
Creates the lazy concatenation of this Iterable and
other
. -
delete(
T element) → Iterable< T> -
Remove the first occurrence of
element
from this Iterable. -
difference(
Eq< T> eq, Iterable<T> other) → Iterable<T> -
Return an Iterable containing the values of this Iterable not included
in
other
based oneq
. -
drop(
int n) → Iterable< T> -
Return the suffix of this Iterable after the first
n
elements. -
dropRight(
[int count = 1]) → Iterable< T> -
Drops the last
count
element of this iterable. -
dropWhileLeft(
bool test(T t)) → Iterable< T> -
Remove all elements starting from the first as long as
test
returnstrue
. -
elem(
T element) → bool -
Check if
element
is contained inside this Iterable. -
filter(
bool test(T t)) → Iterable< T> -
Returns the list of those elements that satisfy
test
. -
filterWithIndex(
bool test(T t, int index)) → Iterable< T> -
Returns the list of those elements that satisfy
test
. -
flatMap<
B> (Iterable< B> toElements(T t)) → Iterable<B> -
For each element of the Iterable apply function
toElements
and flat the result. -
flatMapWithIndex<
B> (Iterable< B> toElements(T t, int index)) → Iterable<B> -
Same as
flatMap
(extend
) but provides also theindex
of each mapped element in the mapping function (toElements
). -
foldLeft<
B> (B initialValue, B combine(B b, T t)) → B - Fold this Iterable into a single value by aggregating each element of the list from the first to the last.
-
foldLeftWithIndex<
B> (B initialValue, B combine(B previousValue, T element, int index)) → B -
Same as
foldLeft
(fold
) but provides also theindex
of each mapped element in thecombine
function. -
insertBy(
Order< T> order, T element) → Iterable<T> -
Insert
element
into the list at the first position where it is less than or equal to the next element based onorder
(Order). -
insertWith<
A> (A extract(T instance), Order< A> order, T element) → Iterable<T> -
Insert
element
into the Iterable at the first position where it is less than or equal to the next element based onorder
(Order). -
intersect(
Iterable< T> iterable) → Iterable<T> - Return the intersection of two Iterable (all the elements that both Iterable have in common).
-
intersperse(
T middle) → Iterable< T> -
Return an Iterable placing an
middle
in between elements of the this Iterable. -
lookupEq(
Eq< T> eq, T element) → Option<T> -
Get first element equal to
element
in this Iterable. -
mapWithIndex<
B> (B toElement(T t, int index)) → Iterable< B> -
Same as
map
but provides also theindex
of each mapped element in the mapping function (toElement
). -
maximumBy(
Order< T> order) → Option<T> -
The largest element of this Iterable based on
order
. -
minimumBy(
Order< T> order) → Option<T> -
The least element of this Iterable based on
order
. -
notElem(
T element) → bool -
Check if
element
is not contained inside this Iterable. -
partition(
bool test(T t)) → (Iterable< T> , Iterable<T> ) -
Return a record containing the values of this Iterable
for which
test
isfalse
in the first element, and the values for which it istrue
in the second element. -
prepend(
T element) → Iterable< T> -
Insert
element
at the beginning of the Iterable. -
prependAll(
Iterable< T> other) → Iterable<T> -
Insert all the elements inside
other
at the beginning of the Iterable. -
sortBy(
Order< T> order) → List<T> -
Sort this List based on
order
(Order). -
sortWith<
A> (A extract(T t), Order< A> order) → List<T> -
Sort this Iterable based on
order
of an object of typeA
extracted fromT
usingextract
. -
sortWithDate(
DateTime getDate(T instance)) → List< T> -
Sort this Iterable based on DateTime extracted from type
T
usinggetDate
. -
span(
bool test(T t)) → (Iterable< T> , Iterable<T> ) -
Return a record where first element is longest prefix (possibly empty) of this Iterable
with elements that satisfy
test
and second element is the remainder of the Iterable. -
splitAt(
int n) → (Iterable< T> , Iterable<T> ) -
Return a record where first element is an Iterable with the first
n
elements of this Iterable, and the second element contains the rest of the Iterable. -
takeWhileLeft(
bool test(T t)) → Iterable< T> -
Extract all elements starting from the first as long as
test
returnstrue
. -
zip<
B> (Iterable< B> iterable) → Iterable<(T, B)> -
zip
is used to join elements at the same index from two different Iterable into one Iterable of a record. -
zipWith<
B, C> (C combine(T t, B b), Iterable< B> iterable) → Iterable<C> -
Join elements at the same index from two different Iterable into
one Iterable containing the result of calling
combine
on each element pair.