Nel
Definitions
def
ap
[aefb]
(
f :
Nel[a -> b \ ef]
l :
Nel[a]
)
: Nel[b]
\ ef
Apply every function from f to every argument from l and return a non-empty 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 :
Nel[a]
l2 :
Nel[a]
)
: Nel[a]
\ Pure
Returns l2 appended to l1.
def
cons
[a]
(
x :
a
l :
Nel[a]
)
: Nel[a]
\ Pure
Returns the non-empty list l prefixed with the new element x.
def
count
[aef]
(
f :
a -> Bool \ ef
l :
Nel[a]
)
: Int32
\ ef
Returns the number of elements in l that satisfy the predicate f.
def
dropWhile
[aef]
(
f :
a -> Bool \ ef
l :
Nel[a]
)
: List[a]
\ ef
Returns l without the longest prefix that satisfies the predicate f.
def
enumerator
[ra]
(
rc :
Region[r]
l :
Nel[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 :
Nel[a]
)
: Bool
\ ef
Returns true if and only if at least one element in l satisfies the predicate f.
def
filter
[a]
(
f :
a -> Bool
l :
Nel[a]
)
: List[a]
\ Pure
Returns a list of every element in l that satisfies the predicate f.
def
find
[aef]
(
f :
a -> Bool \ ef
l :
Nel[a]
)
: Option[a]
\ ef
Alias for findLeft.
def
findLeft
[aef]
(
f :
a -> Bool \ ef
l :
Nel[a]
)
: Option[a]
\ ef
Optionally returns the first element of l that satisfies the predicate f when searching from left to right.
def
findRight
[aef]
(
f :
a -> Bool \ ef
l :
Nel[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 -> Nel[b] \ ef
l :
Nel[a]
)
: Nel[b]
\ ef
Returns the result of applying f to every element in l and concatenating the results.
def
flatten
[a]
(
l :
Nel[Nel[a]]
)
: Nel[a]
\ Pure
Returns the concatenation of the elements in l.
def
fold
[a]
(
l :
Nel[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
foldLeft
[baef]
(
f :
b -> (a -> b \ ef)
s :
b
l :
Nel[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
foldMap
[aefb]
(
f :
a -> b \ ef
l :
Nel[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 :
Nel[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
foldRightWithCont
[aefb]
(
f :
a -> ((Unit -> b \ ef) -> b \ ef)
z :
b
l :
Nel[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 :
Nel[a]
)
: Bool
\ ef
Returns true if and only if all elements in l satisfy the predicate f.
def
forEach
[aef]
(
f :
a -> Unit \ ef
l :
Nel[a]
)
: Unit
\ ef
Applies f to every element of l.
def
forEachWithIndex
[aef]
(
f :
Int32 -> (a -> Unit \ ef)
l :
Nel[a]
)
: Unit
\ ef
Applies f to every element of l along with that element's index.
def
head
[a]
(
l :
Nel[a]
)
: a
\ Pure
Returns the first element of l.
def
init
[a]
(
l :
Nel[a]
)
: List[a]
\ Pure
Returns all elements in l without the last element.
def
intersperse
[a]
(
a :
a
l :
Nel[a]
)
: Nel[a]
\ Pure
Returns l with a inserted between every two adjacent elements.
def
iterator
[ra]
(
rc :
Region[r]
l :
Nel[a]
)
: Iterator[a, r, r]
\ r
Returns an iterator over l.
def
join
[a]
(
sep :
String
l :
Nel[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 :
Nel[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 :
Nel[a]
)
: a
\ Pure
Returns the last element of l.
def
length
[a]
(
l :
Nel[a]
)
: Int32
\ Pure
Returns the length of l.
def
map
[aefb]
(
f :
a -> b \ ef
l :
Nel[a]
)
: Nel[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
mapWithIndex
[aefb]
(
f :
Int32 -> (a -> b \ ef)
l :
Nel[a]
)
: Nel[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 :
Nel[a]
)
: a
\ Pure
with
Order[a]
Finds the largest element of l according to the Order on a.
def
maximumBy
[a]
(
cmp :
a -> (a -> Comparison)
l :
Nel[a]
)
: a
\ Pure
Finds the largest element of l according to the given comparator cmp.
def
memberOf
[a]
(
a :
a
l :
Nel[a]
)
: Bool
\ Pure
with
Eq[a]
Returns true if and only if l contains the element a.
def
minimum
[a]
(
l :
Nel[a]
)
: a
\ Pure
with
Order[a]
Finds the smallest element of l according to the Order on a.
def
minimumBy
[a]
(
cmp :
a -> (a -> Comparison)
l :
Nel[a]
)
: a
\ Pure
Finds the smallest element of l according to the given comparator cmp.
def
permutations
[a]
(
l :
Nel[a]
)
: Nel[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
reduce
[a]
(
l :
Nel[a]
)
: a
\ Pure
with
SemiGroup[a]
Applies combine to all elements in l until a single value is obtained.
def
reduceLeft
[aef]
(
f :
a -> (a -> a \ ef)
l :
Nel[a]
)
: a
\ ef
Applies f to all elements in l going from left to right until a single value v is obtained.
That is, the result is of the form: f(...f(f(x1, x2), x3)..., xn)
def
reduceLeftTo
[baef1ef2]
(
f :
b -> (a -> b \ ef1)
g :
a -> b \ ef2
l :
Nel[a]
)
: b
\ ef1 + ef2
Left-associative reduction of a structure.
Applies g to the initial element of l and combines it
with the remainder of l using f going from left to right.
def
reduceRight
[aef]
(
f :
a -> (a -> a \ ef)
l :
Nel[a]
)
: a
\ ef
Applies f to all elements in l going from right to left until a single value v is obtained.
That is, the result is of the form: Some(f(x1, ...f(xn-2, f(xn-1, xn))...))
def
reduceRightTo
[abef1ef2]
(
f :
a -> (b -> b \ ef1)
g :
a -> b \ ef2
l :
Nel[a]
)
: b
\ ef1 + ef2
Right-associative reduction of a structure.
Applies g to the initial element of l and combines it
with the remainder of l using f going from right to left.
def
replace
[a]
(
from :
{ from = a }
to :
{ to = a }
l :
Nel[a]
)
: Nel[a]
\ Pure
with
Eq[a]
Returns l with every occurrence of from replaced by to.
def
reverse
[a]
(
l :
Nel[a]
)
: Nel[a]
\ Pure
Returns the reverse of l.
def
sequence
[ma]
(
l :
Nel[m[a]]
)
: m[Nel[a]]
\ Pure
with
Applicative[m]
Returns the result of applying the applicative mapping function f to all the elements of the
non-empty list l.
def
shuffle
[a]
(
rnd :
Random
l :
Nel[a]
)
: Option[Nel[a]]
\ IO
Optionally returns the Nel l shuffled using the Fisher–Yates shuffle.
def
singleton
[a]
(
x :
a
)
: Nel[a]
\ Pure
Returns a new non-empty list containing the single element x.
def
sort
[a]
(
l :
Nel[a]
)
: Nel[a]
\ Pure
with
Order[a]
Sort the non-empty 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 :
Nel[a]
)
: Nel[a]
\ Pure
with
Order[b]
Sort the non-empty 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 :
Nel[a]
)
: Nel[a]
\ Pure
Sort the non-empty 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
subsequences
[a]
(
l :
Nel[a]
)
: Nel[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 :
Nel[Int32]
)
: Int32
\ Pure
Returns the sum of all elements in the list l.
def
sumWith
[aef]
(
f :
a -> Int32 \ ef
l :
Nel[a]
)
: Int32
\ ef
Returns the sum of all elements in the list l according to the function f.
def
tail
[a]
(
l :
Nel[a]
)
: List[a]
\ Pure
Returns all elements in l without the first element.
def
takeWhile
[aef]
(
f :
a -> Bool \ ef
l :
Nel[a]
)
: List[a]
\ ef
Returns the longest prefix of l that satisfies the predicate f.
def
toArray
[ra]
(
rc :
Region[r]
l :
Nel[a]
)
: Array[a, r]
\ r
Returns l as an array.
def
toList
[a]
(
l :
Nel[a]
)
: List[a]
\ Pure
Returns l as a normal list.
def
toMapWith
[ab]
(
f :
a -> b
l :
Nel[a]
)
: Map[a, b]
\ Pure
with
Order[a]
Returns a map with elements of l as keys and f applied as values.
If l 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 :
Nel[a]
)
: MutDeque[a, r]
\ r
Returns l as a MutDeque.
def
toString
[a]
(
l :
Nel[a]
)
: String
\ Pure
with
ToString[a]
Returns a string representation of the given non-empty list l.
def
toVector
[a]
(
l :
Nel[a]
)
: Vector[a]
\ Pure
Returns l as a vector.
def
traverse
[aefmb]
(
f :
a -> m[b] \ ef
l :
Nel[a]
)
: m[Nel[b]]
\ ef
with
Applicative[m]
Returns the result of running all the actions in the non-empty list l.
def
unzip
[ab]
(
l :
Nel[(a, b)]
)
: (Nel[a], Nel[b])
\ Pure
Returns a pair of non-empty lists, the first containing all first components in l
and the second containing all second components in l.
def
zip
[ab]
(
l1 :
Nel[a]
l2 :
Nel[b]
)
: Nel[(a, b)]
\ Pure
Returns a non-empty 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
zipWith
[abefc]
(
f :
a -> (b -> c \ ef)
l1 :
Nel[a]
l2 :
Nel[b]
)
: Nel[c]
\ ef
Returns a non-empty 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
zipWithA
[abefmc]
(
f :
a -> (b -> m[c] \ ef)
xs :
Nel[a]
ys :
Nel[b]
)
: m[Nel[c]]
\ ef
with
Applicative[m]
Generalize zipWith to an applicative functor f.
def
zipWithIndex
[a]
(
l :
Nel[a]
)
: Nel[(Int32, a)]
\ Pure
Returns a new non-empty list where each element e is mapped to (i, e)
where i is the index of e.