List
Definitions
def
ap
[aefb]
(
f :
List[a -> b \ ef]
x :
List[a]
)
: List[b]
\ ef
Apply every function from f
to every argument from x
and return a list with all results.
For f = f1, f2, ...
and x = x1, x2, ...
the results appear in the order
f1(x1), f1(x2), ..., f2(x1), f2(x2), ...
.
def
append
[a]
(
l1 :
List[a]
l2 :
List[a]
)
: List[a]
\ Pure
Returns l2
appended to l1
.
The infix operator :::
is an alias for append
(l1 ::: l2 = append(l1, l2)
).
def
count
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: Int32
\ ef
Returns the number of elements in l
that satisfy the predicate f
.
def
distinct
[a]
(
l :
List[a]
)
: List[a]
\ Pure
with
Eq[a]
Returns the list l
with duplicates removed. The first occurence of
an element is kept and except for the removal of subsequent duplicates
the order of l
is preserved.
distinct
uses the Flix's builtin equality test. Use distinctWith
if you
need a custom equality test.
def
distinctWith
[a]
(
f :
a -> (a -> Bool)
l :
List[a]
)
: List[a]
\ Pure
Returns the list l
with duplicates removed using the supplied function
f
for comparison. The first occurrence of an element is kept and except
for the removal of subsequent duplicates the order of l
is preserved.
def
drop
[a]
(
n :
Int32
l :
List[a]
)
: List[a]
\ Pure
Returns l
without the first n
elements.
Returns Nil
if n > length(l)
.
Returns l
if n < 0
.
def
dropWhile
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: List[a]
\ ef
Returns l
without the longest prefix that satisfies the predicate f
.
def
enumerator
[ra]
(
rc :
Region[r]
l :
List[a]
)
: Iterator[(Int32, a), r, r]
\ r
Returns an iterator over l
zipped with the indices of the elements.
def
exists
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: Bool
\ ef
Returns true
if and only if at least one element in l
satisfies the predicate f
.
Returns false
if l
is empty.
def
filter
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: List[a]
\ ef
Returns a list of every element in l
that satisfies the predicate f
.
def
filterMap
[aefb]
(
f :
a -> Option[b] \ ef
l :
List[a]
)
: List[b]
\ ef
Collects the results of applying the partial function f
to every element in l
.
def
find
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: Option[a]
\ ef
Alias for findLeft
.
def
findLeft
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: Option[a]
\ ef
Optionally returns the first element of l
that satisfies the predicate f
when searching from left to right.
def
findMap
[aefb]
(
f :
a -> Option[b] \ ef
l :
List[a]
)
: Option[b]
\ ef
Returns the first non-None result of applying the partial function f
to each element of l
.
Returns None
if every element of l
is None
.
def
findRight
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: Option[a]
\ ef
Optionally returns the first element of l
that satisfies the predicate f
when searching from right to left.
def
flatMap
[aefb]
(
f :
a -> List[b] \ ef
l :
List[a]
)
: List[b]
\ ef
Returns the result of applying f
to every element in l
and concatenating the results.
def
flatten
[a]
(
l :
List[List[a]]
)
: List[a]
\ Pure
Returns the concatenation of the elements in l
.
def
fold
[a]
(
l :
List[a]
)
: a
\ Pure
with
Monoid[a]
Returns the result of applying combine
to all the elements in l
, using empty
as the initial value.
def
fold2
[cabef]
(
f :
c -> (a -> (b -> c \ ef))
c :
c
l1 :
List[a]
l2 :
List[b]
)
: c
\ ef
Alias for foldLeft2
.
def
foldLeft
[baef]
(
f :
b -> (a -> b \ ef)
s :
b
l :
List[a]
)
: b
\ ef
Applies f
to a start value s
and all elements in l
going from left to right.
That is, the result is of the form: f(...f(f(s, x1), x2)..., xn)
.
def
foldLeft2
[cabef]
(
f :
c -> (a -> (b -> c \ ef))
c :
c
l1 :
List[a]
l2 :
List[b]
)
: c
\ ef
Accumulates the result of applying f
pairwise to the elements of l1
and l2
starting with the initial value c
and going from left to right.
def
foldMap
[aefb]
(
f :
a -> b \ ef
l :
List[a]
)
: b
\ ef
with
Monoid[b]
Returns the result of mapping each element and combining the results.
def
foldRight
[abef]
(
f :
a -> (b -> b \ ef)
s :
b
l :
List[a]
)
: b
\ ef
Applies f
to a start value s
and all elements in l
going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...)
.
def
foldRight2
[abcef]
(
f :
a -> (b -> (c -> c \ ef))
c :
c
l1 :
List[a]
l2 :
List[b]
)
: c
\ ef
Accumulates the result of applying f
pairwise to the elements of l1
and l2
starting with the initial value c
and going from right to left.
def
foldRightWithCont
[aefb]
(
f :
a -> ((Unit -> b \ ef) -> b \ ef)
z :
b
l :
List[a]
)
: b
\ ef
Applies f
to a start value z
and all elements in l
going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, z))...)
.
A foldRightWithCont
allows early termination by not calling the continuation.
def
forAll
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: Bool
\ ef
Returns true
if and only if all elements in l
satisfy the predicate f
.
Returns true
if l
is empty.
def
forEach
[aef]
(
f :
a -> Unit \ ef
l :
List[a]
)
: Unit
\ ef
Applies f
to every element of l
.
def
forEachWithIndex
[aef]
(
f :
Int32 -> (a -> Unit \ ef)
l :
List[a]
)
: Unit
\ ef
Applies f
to every element of l
along with that element's index.
def
groupBy
[a]
(
f :
a -> (a -> Bool)
l :
List[a]
)
: List[List[a]]
\ Pure
Partitions l
into sublists such that for any two elements x
and y
in a sublist, f(x, y)
is true.
A sublist is created by iterating through the remaining elements of l
from left to right and adding an
element to the sublist if and only if doing so creates no conflicts with the elements already in the sublist.
The function f
must be pure.
def
head
[a]
(
l :
List[a]
)
: Option[a]
\ Pure
Returns Some(x)
if x
is the first element of l
.
Returns None
if l
is empty.
def
indexOf
[a]
(
a :
a
l :
List[a]
)
: Option[Int32]
\ Pure
with
Eq[a]
Optionally returns the position of x
in l
.
def
init
[a]
(
l :
List[a]
)
: Option[List[a]]
\ Pure
Returns the sublist of l
without the last element.
Returns None
if the list l
is Nil
.
def
intercalate
[a]
(
l1 :
List[a]
l2 :
List[List[a]]
)
: List[a]
\ Pure
Returns the concatenation of the elements in l2
with the elements of l1
inserted between every two adjacent elements.
That is, returns y1 :: x1 ... xn :: y2 :: ... yn-1 :: x1 :: ... :: xn :: yn :: Nil
.
def
intersperse
[a]
(
a :
a
l :
List[a]
)
: List[a]
\ Pure
Returns l
with x
inserted between every two adjacent elements.
def
isEmpty
[a]
(
l :
List[a]
)
: Bool
\ Pure
Returns true if and only if l
is the empty list, i.e. Nil
.
def
isInfixOf
[a]
(
l1 :
List[a]
l2 :
List[a]
)
: Bool
\ Pure
with
Eq[a]
Returns true
if and only if l1
is an infix of l2
.
def
isPrefixOf
[a]
(
l1 :
List[a]
l2 :
List[a]
)
: Bool
\ Pure
with
Eq[a]
Returns true
if and only if l1
is a prefix of l2
.
def
isSuffixOf
[a]
(
l1 :
List[a]
l2 :
List[a]
)
: Bool
\ Pure
with
Eq[a]
Returns true
if and only if l1
is a suffix of l2
.
def
iterator
[ra]
(
rc :
Region[r]
xs :
List[a]
)
: Iterator[a, r, r]
\ r
Returns an iterator over l
.
def
join
[a]
(
sep :
String
l :
List[a]
)
: String
\ Pure
with
ToString[a]
Returns the concatenation of the string representation
of each element in l
with sep
inserted between each element.
def
joinWith
[aef]
(
f :
a -> String \ ef
sep :
String
l :
List[a]
)
: String
\ ef
Returns the concatenation of the string representation
of each element in l
according to f
with sep
inserted between each element.
def
last
[a]
(
l :
List[a]
)
: Option[a]
\ Pure
Returns Some(x)
if x
is the last element of l
.
Returns None
if l
is empty.
def
length
[a]
(
l :
List[a]
)
: Int32
\ Pure
Returns the length of l
.
def
map
[aefb]
(
f :
a -> b \ ef
l :
List[a]
)
: List[b]
\ ef
Returns the result of applying f
to every element in l
.
That is, the result is of the form: f(x1) :: f(x2) :: ...
.
def
map2
[t1t2efr]
(
f :
t1 -> (t2 -> r \ ef)
l1 :
List[t1]
l2 :
List[t2]
)
: List[r]
\ ef
Lift a binary function to work on lists of its original arguments, returning a list
of applying all combinations of arguments.
For argument lists l1 = x1, x2, ...
and l2 = y1, y2, ...
the results appear in the order
f(x1,y1), f(x1,y2), ..., f(x2,y1), f(x2,y2), ...
.
def
map3
[t1t2t3efr]
(
f :
t1 -> (t2 -> (t3 -> r \ ef))
l1 :
List[t1]
l2 :
List[t2]
l3 :
List[t3]
)
: List[r]
\ ef
Lift a ternary function to work on lists of its original arguments, returning a list
of applying all combinations of arguments.
For argument lists l1 = x1, x2, ...
, l2 = y1, y2, ...
and l3 = z1, z2, ...
the results appear
in the following order:
f(x1,y1,z1), f(x1,y1,z2), ..., f(x1,y2,z1), f(x1,y2,z2), ...,
f(x2,y1,z1), f(x2,y1,z2), ..., f(x2,y2,z1), f(x2,y2,z2), ...`
...
def
map4
[t1t2t3t4efr]
(
f :
t1 -> (t2 -> (t3 -> (t4 -> r \ ef)))
l1 :
List[t1]
l2 :
List[t2]
l3 :
List[t3]
l4 :
List[t4]
)
: List[r]
\ ef
Lift a 4-ary function to work on lists of its original arguments, returning a list
of applying all combinations of arguments. The results appear in the order extending the pattern from map3
.
def
map5
[t1t2t3t4t5efr]
(
f :
t1 -> (t2 -> (t3 -> (t4 -> (t5 -> r \ ef))))
l1 :
List[t1]
l2 :
List[t2]
l3 :
List[t3]
l4 :
List[t4]
l5 :
List[t5]
)
: List[r]
\ ef
Lift a 5-ary function to work on lists of its original arguments, returning a list
of applying all combinations of arguments. The results appear in the order extending the pattern from map3
.
def
mapWithIndex
[aefb]
(
f :
Int32 -> (a -> b \ ef)
l :
List[a]
)
: List[b]
\ ef
Returns the result of applying f
to every element in l
along with that element's index.
That is, the result is of the form: f(x1, 0) :: f(x2, 1) :: ...
.
def
maximum
[a]
(
l :
List[a]
)
: Option[a]
\ Pure
with
Order[a]
Optionally finds the largest element of l
according to the Order
on a
.
Returns None
if l
is empty.
def
maximumBy
[a]
(
cmp :
a -> (a -> Comparison)
l :
List[a]
)
: Option[a]
\ Pure
Optionally finds the largest element of l
according to the given comparator cmp
.
Returns None
if l
is empty.
def
memberOf
[a]
(
a :
a
l :
List[a]
)
: Bool
\ Pure
with
Eq[a]
Returns true
if and only if l
contains the element x
.
def
merge
[a]
(
l1 :
List[a]
l2 :
List[a]
)
: List[a]
\ Pure
with
Order[a]
Merges the two lists l1
and l2
. Assuming they are both sorted.
If two elements compare EqualTo
, then the element of l1
is first in the result.
def
minimum
[a]
(
l :
List[a]
)
: Option[a]
\ Pure
with
Order[a]
Optionally finds the smallest element of l
according to the Order
on a
.
Returns None
if l
is empty.
def
minimumBy
[a]
(
cmp :
a -> (a -> Comparison)
l :
List[a]
)
: Option[a]
\ Pure
Optionally finds the smallest element of l
according to the given comparator cmp
.
Returns None
if l
is empty.
def
partition
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: (List[a], List[a])
\ ef
Returns a pair of lists (l1, l2)
.
l1
contains all elements of l
that satisfy the predicate f
.
l2
contains all elements of l
that do not satisfy the predicate f
.
def
patch
[a]
(
i :
Int32
n :
Int32
l1 :
List[a]
l2 :
List[a]
)
: List[a]
\ Pure
Returns l2
with the n
elements starting at index i
replaced with the elements of l1
.
If any of the indices i, i+1, i+2, ... , i+n-1
are out of range in l2
then no patching is done at these indices.
If l1
becomes depleted then no further patching is done.
If patching occurs at index i+j
in l2
, then the element at index j
in l1
is used.
def
permutations
[a]
(
l :
List[a]
)
: List[List[a]]
\ Pure
Returns all permutations of l
in lexicographical order by element indices in l
.
That is, l
is the first permutation and reverse(l)
is the last permutation.
def
point
[a]
(
a :
a
)
: List[a]
\ Pure
Return the singleton list with element x
.
def
range
(
b :
Int32
e :
Int32
)
: List[Int32]
\ Pure
Returns a list of all integers between b
(inclusive) and e
(exclusive).
Returns Nil
if b >= e
.
def
reduceLeft
[aef]
(
f :
a -> (a -> a \ ef)
l :
List[a]
)
: Option[a]
\ ef
Applies f
to all elements in l
going from left to right until a single value v
is obtained. Returns Some(v)
.
That is, the result is of the form: Some(f(...f(f(x1, x2), x3)..., xn))
Returns None
if l
is empty.
def
reduceRight
[aef]
(
f :
a -> (a -> a \ ef)
l :
List[a]
)
: Option[a]
\ ef
Applies f
to all elements in l
going from right to left until a single value v
is obtained. Returns Some(v)
.
That is, the result is of the form: Some(f(x1, ...f(xn-2, f(xn-1, xn))...))
Returns None
if l
is empty.
def
repeat
[a]
(
n :
Int32
a :
a
)
: List[a]
\ Pure
Returns a list with the element x
repeated n
times.
Returns Nil
if n < 0
.
def
replace
[a]
(
from :
{ from = a }
to :
{ to = a }
l :
List[a]
)
: List[a]
\ Pure
with
Eq[a]
Returns l
with every occurrence of from
replaced by to
.
def
reverse
[a]
(
l :
List[a]
)
: List[a]
\ Pure
Returns the reverse of l
.
def
rotateLeft
[a]
(
n :
Int32
l :
List[a]
)
: List[a]
\ Pure
Returns l
with its elements rotated n
positions to the left.
That is, returns a new list where the first n mod length(l)
elements in l
are the last n mod length(l)
elements of the new list.
def
rotateRight
[a]
(
n :
Int32
l :
List[a]
)
: List[a]
\ Pure
Returns l
with its elements rotated n
positions to the right.
That is, returns a new list where the last n mod length(l)
elements in l
are the first n mod length(l)
elements of the new list.
def
scan
[baef]
(
f :
b -> (a -> b \ ef)
s :
b
l :
List[a]
)
: List[b]
\ ef
Alias for scanLeft
.
def
scanLeft
[baef]
(
f :
b -> (a -> b \ ef)
s :
b
l :
List[a]
)
: List[b]
\ ef
Accumulates the result of applying f
to l
going left to right.
That is, the result is of the form: s :: f(s, x1) :: f(f(s, x1), x2) ...
.
def
scanRight
[abef]
(
f :
a -> (b -> b \ ef)
s :
b
l :
List[a]
)
: List[b]
\ ef
Accumulates the result of applying f
to l
going right to left.
That is, the result is of the form: ... f(xn-1, f(xn, s)) :: f(xn, s) :: s
.
def
sequence
[ma]
(
l :
List[m[a]]
)
: m[List[a]]
\ Pure
with
Applicative[m]
Returns the result of running all the actions in the list l
going from left
to right.
def
shuffle
[a]
(
rnd :
Random
l :
List[a]
)
: List[a]
\ IO
Shuffles l
using the Fisher–Yates shuffle.
def
slice
[a]
(
start :
{ start = Int32 }
end :
{ end = Int32 }
l :
List[a]
)
: List[a]
\ Pure
Returns the sublist of l
from index start
(inclusive) to index end
(exclusive).
That is, an element at index i
in l
is part of the returned sublist if and only if i >= start
and i < end
.
Note: Indices that are out of bounds in l
are not considered (i.e. slice(start, end, l) = slice(max(0, start), min(length(l), end), l)).
def
sort
[a]
(
l :
List[a]
)
: List[a]
\ Pure
with
Order[a]
Sort list l
so that elements are ordered from low to high according to their Order
instance.
The sort is not stable, i.e., equal elements may appear in a different order than in the input l
.
The sort implementation is a Quicksort.
def
sortBy
[ab]
(
f :
a -> b
l :
List[a]
)
: List[a]
\ Pure
with
Order[b]
Sort list l
so that elements are ordered from low to high according to the Order
instance
for the values obtained by applying f
to each element.
The sort is not stable, i.e., equal elements may appear in a different order than in the input l
.
The sort implementation is a Quicksort.
def
sortWith
[a]
(
cmp :
a -> (a -> Comparison)
l :
List[a]
)
: List[a]
\ Pure
Sort list l
so that elements are ordered from low to high according to the comparison function cmp
.
The sort is not stable, i.e., equal elements may appear in a different order than in the input l
.
The sort implementation is a Quicksort.
def
span
[a]
(
f :
a -> Bool
l :
List[a]
)
: (List[a], List[a])
\ Pure
Returns a pair of lists (l1, l2)
.
l1
is the longest prefix of l
that satisfies the predicate f
.
l2
is the remainder of l
.
The function f
must be pure.
def
splitAt
[a]
(
n :
Int32
xs :
List[a]
)
: (List[a], List[a])
\ Pure
Split the list xs
at the position n
returning the left and right parts.
Position n
is included in the right part.
Example: splitAt(2, 1::2::3::4::Nil)
returns (1::2::Nil, 3::4::Nil)
Returns (xs, Nil)
if n > length(xs)
.
Returns (Nil, xs)
if n < 0
.
def
subsequences
[a]
(
l :
List[a]
)
: List[List[a]]
\ Pure
Returns all subsequences of l
in lexicographical order by element indices in l
.
That is, l
is the first subsequence and Nil
is the last subsequence.
def
sum
(
l :
List[Int32]
)
: Int32
\ Pure
Returns the sum of all elements in the list l
.
def
sumWith
[aef]
(
f :
a -> Int32 \ ef
l :
List[a]
)
: Int32
\ ef
Returns the sum of all elements in the list l
according to the function f
.
def
take
[a]
(
n :
Int32
l :
List[a]
)
: List[a]
\ Pure
Returns the first n
elements of l
.
Returns l
if n > length(l)
.
Returns Nil
if n < 0
.
def
takeWhile
[aef]
(
f :
a -> Bool \ ef
l :
List[a]
)
: List[a]
\ ef
Returns the longest prefix of l
that satisfies the predicate f
.
def
toArray
[ra]
(
rc :
Region[r]
l :
List[a]
)
: Array[a, r]
\ r
Returns the list l
as an array.
def
toChain
[a]
(
l :
List[a]
)
: Chain[a]
\ Pure
Returns the list l
as a chain.
def
toDelayList
[a]
(
l :
List[a]
)
: DelayList[a]
\ Pure
Returns the elements of l
as a DelayList
.
def
toDelayMap
[ab]
(
l :
List[(a, b)]
)
: DelayMap[a, b]
\ Pure
with
Order[a]
Returns the association list l
as a DelayMap
.
If l
contains multiple mappings with the same key, toDelayMap
does not
make any guarantees about which mapping will be in the resulting map.
def
toMap
[ab]
(
l :
List[(a, b)]
)
: Map[a, b]
\ Pure
with
Order[a]
Returns the association list l
as a map.
If l
contains multiple mappings with the same key, toMap
does not
make any guarantees about which mapping will be in the resulting map.
def
toMapWith
[ab]
(
f :
a -> b
l :
List[a]
)
: Map[a, b]
\ Pure
with
Order[a]
Returns a map with elements of s
as keys and f
applied as values.
If s
contains multiple mappings with the same key, toMapWith
does not
make any guarantees about which mapping will be in the resulting map.
def
toMutDeque
[ra]
(
rc :
Region[r]
l :
List[a]
)
: MutDeque[a, r]
\ r
Returns l
as a MutDeque.
def
toMutList
[ra]
(
rc :
Region[r]
l :
List[a]
)
: MutList[a, r]
\ r
Returns l
as a mutable list.
def
toNec
[a]
(
l :
List[a]
)
: Option[Nec[a]]
\ Pure
Returns the list l
as Option[Nec[a]]
.
If l
is empty return None
, otherwise return the Nec wrapped in Some
.
def
toNel
[a]
(
l :
List[a]
)
: Option[Nel[a]]
\ Pure
Returns the list l
as Option[Nel[a]]
.
If l
is empty return None
, otherwise return the Nel wrapped in Some
.
def
toSet
[a]
(
l :
List[a]
)
: Set[a]
\ Pure
with
Order[a]
Returns the list l
as a set.
def
toString
[a]
(
l :
List[a]
)
: String
\ Pure
with
ToString[a]
Renders the list l
to a String.
def
toVector
[a]
(
l :
List[a]
)
: Vector[a]
\ Pure
Returns the list l
as a vector.
def
transpose
[a]
(
l :
List[List[a]]
)
: List[List[a]]
\ Pure
Returns the transpose of l
.
Returns l
if the dimensions of the elements of l
are mismatched.
def
traverse
[aefmb]
(
f :
a -> m[b] \ ef
l :
List[a]
)
: m[List[b]]
\ ef
with
Applicative[m]
Returns the result of applying the applicative mapping function f
to all the elements of the
list l
going from left to right.
def
unfold
[sefa]
(
f :
s -> Option[(a, s)] \ ef
st :
s
)
: List[a]
\ ef
Build a list by applying f
to the seed value st
.
f
should return Some(a,st1)
to signal a new list element a
and a new seed value st1
.
f
should return None
to signal the end of building the list.
def
unfoldWithIter
[efa]
(
next :
Unit -> Option[a] \ ef
)
: List[a]
\ ef
Build a list by applying the function next
to ()
. next
is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next
should return Some(a)
to signal a new list element a
.
next
should return None
to signal the end of building the list.
def
unfoldWithOkIter
[efea]
(
next :
Unit -> Result[e, Option[a]] \ ef
)
: Result[e, List[a]]
\ ef
Build a list by applying the function next
to ()
. next
is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next
should return Ok(Some(a)
to signal a new list element Ok(a)
.
next
should return Ok(None)
to signal the end of building the list.
next
should return Err(e)
to signal that an error occurred. The function returns Err(e)
.
def
unzip
[ab]
(
l :
List[(a, b)]
)
: (List[a], List[b])
\ Pure
Returns a pair of lists, the first containing all first components in l
and the second containing all second components in l
.
def
unzip3
[abc]
(
l :
List[(a, b, c)]
)
: (List[a], List[b], List[c])
\ Pure
Returns a triple of lists, the first containing all first components in l
the second containing all second components in l
and the third containing all
third components in l
.
def
update
[a]
(
i :
Int32
a :
a
l :
List[a]
)
: List[a]
\ Pure
Returns l
with the element at index i
replaced by x
.
Returns l
if i < 0
or i > length(l)-1
.
def
zip
[ab]
(
l1 :
List[a]
l2 :
List[b]
)
: List[(a, b)]
\ Pure
Returns a list where the element at index i
is (a, b)
where
a
is the element at index i
in l1
and b
is the element at index i
in l2
.
If either l1
or l2
becomes depleted, then no further elements are added to the resulting list.
def
zip3
[abc]
(
l1 :
List[a]
l2 :
List[b]
l3 :
List[c]
)
: List[(a, b, c)]
\ Pure
Returns a list where the element at index i
is (a, b, c)
where
a
is the element at index i
in l1
, b
is the element at index i
in l2
and c
is the element at index i
in l3
.
If any one of l1
, l2
or l3
become depleted, then no further elements are added to the resulting list.
def
zipWith
[abefc]
(
f :
a -> (b -> c \ ef)
l1 :
List[a]
l2 :
List[b]
)
: List[c]
\ ef
Returns a list where the element at index i
is f(a, b)
where
a
is the element at index i
in l1
and b
is the element at index i
in l2
.
If either l1
or l2
becomes depleted, then no further elements are added to the resulting list.
def
zipWith3
[abcefd]
(
f :
a -> (b -> (c -> d \ ef))
l1 :
List[a]
l2 :
List[b]
l3 :
List[c]
)
: List[d]
\ ef
Returns a list where the element at index i
is f(a, b, c)
where
a
is the element at index i
in l1
, b
is the element at index i
in l2
and c
is the element at index i
in l3
.
If any one of l1
, l2
or l3
become depleted, then no further elements are added to the resulting list.
def
zipWithA
[abeffc]
(
f :
a -> (b -> f[c] \ ef)
xs :
List[a]
ys :
List[b]
)
: f[List[c]]
\ ef
with
Applicative[f]
Generalize zipWith
to an applicative functor f
.
def
zipWithIndex
[a]
(
l :
List[a]
)
: List[(Int32, a)]
\ Pure
Returns a list where each element e
is mapped to (i, e)
where i
is the index of e
.