Array

Definitions

def append(rc3: Region[r3], a: Array[a, r1], b: Array[a, r2]): Array[a, r3] \ r1 + r2 + r3 Source

Return a new array, appending the elements b to elements of a.

def compare(a: Array[v, r1], b: Array[v, r2]): Comparison \ r1 + r2 with Order[v] Source

Compares a and b lexicographically.

def copyOfRange(_: Region[r2], b: Int32, e: Int32, a: Array[a, r1]): Array[a, r2] \ r1 + r2 Source

Copies the range between b (inclusive) and e (exclusive) of a into an empty array.

A valid range has the following properties: - 0 <= b <= length(a). - e >= b. If the range is valid and greater than the length of a, the resulting array with have the length of the range and include the specified range of a.

def count(f: a -> Bool \ ef, a: Array[a, r]): Int32 \ ef + r Source

Returns the number of elements in a that satisfy the predicate f.

def drop(rc1: Region[r1], n: Int32, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Alias for dropLeft.

def dropLeft(rc1: Region[r1], n: Int32, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a copy of array a, dropping the first n elements.

Returns [] if n > length(a).

def dropRight(rc1: Region[r1], n: Int32, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a copy of array a, dropping the last n elements.

Returns [] if n > length(a).

def dropWhile(rc1: Region[r1], f: a -> Bool \ ef, a: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Alias for dropWhileLeft.

def dropWhileLeft(rc1: Region[r1], f: a -> Bool \ ef, a: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Returns copy of array a without the longest prefix that satisfies the predicate f.

def dropWhileRight(rc1: Region[r1], f: a -> Bool \ ef, a: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Returns copy of array a without the longest suffix that satisfies the predicate f.

def empty(rc: Region[r], l: Int32): Array[a, r] \ r Source

Returns a new uninitialized array of length l in the region r.

def enumerator(rc: Region[r1], a: Array[a, r2]): Iterator[(Int32, a), r1 + r2, r1] \ r1 Source

Returns an iterator over a zipped with the indices of the elements.

Modifying a while using an iterator has undefined behavior and is dangerous.

def exists(f: a -> Bool \ ef, arr: Array[a, r]): Bool \ ef + r Source

Returns true if and only if at least one element in arr satisfies the predicate f.

Returns false if arr is empty.

def filter(rc1: Region[r1], f: a -> Bool \ ef, arr: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Returns an array of every element in arr that satisfies the predicate f.

def filterMap(rc1: Region[r1], f: a -> Option[b] \ ef, a: Array[a, r]): Array[b, r1] \ ef + r + r1 Source

Collects the results of applying the partial function f to every element in a.

def find(f: a -> Bool \ ef, arr: Array[a, r]): Option[a] \ ef + r Source

Alias for findLeft.

def findIndexOf(f: a -> Bool \ ef, a: Array[a, r]): Option[Int32] \ ef + r Source

Alias for findIndexOfLeft.

def findIndexOfLeft(f: a -> Bool \ ef, a: Array[a, r]): Option[Int32] \ ef + r Source

Optionally returns the position of the first element in x satisfying f.

def findIndexOfRight(f: a -> Bool \ ef, a: Array[a, r]): Option[Int32] \ ef + r Source

Optionally returns the position of the first element in a satisfying f searching from right to left.

def findIndices(rc2: Region[r2], f: a -> Bool \ ef, a: Array[a, r1]): Array[Int32, r2] \ ef + r1 + r2 Source

Returns the positions of the all the elements in a satisfying f.

def findLeft(f: a -> Bool \ ef, arr: Array[a, r]): Option[a] \ ef + r Source

Optionally returns the first element of a that satisfies the predicate f when searching from left to right.

def findMap(f: a -> Option[b] \ ef, a: Array[a, r]): Option[b] \ ef + r Source

Returns the first non-None result of applying the partial function f to each element of xs.

Returns None if every element of xs is None.

def findRight(f: a -> Bool \ ef, arr: Array[a, r]): Option[a] \ ef + r Source

Optionally returns the first element of xs that satisfies the predicate f when searching from right to left.

def flatMap(rc1: Region[r1], f: a -> Array[b, r1] \ ef, a: Array[a, r]): Array[b, r1] \ ef + r + r1 Source

Returns the result of applying f to every element in a and concatenating the results.

def flatten(rc1: Region[r1], arrs: Array[Array[a, r], r]): Array[a, r1] \ r + r1 Source

Returns the concatenation of the arrays of in the array arrs.

def fold(arr: Array[a, r]): a \ r with Monoid[a] Source

Returns the result of applying combine to all the elements in a, using empty as the initial value.

def fold2(f: c -> (a -> (b -> c \ ef)), c: c, a: Array[a, r1], b: Array[b, r2]): c \ ef + r1 + r2 Source

Alias for foldLeft2.

def foldLeft(f: b -> (a -> b \ ef), s: b, arr: Array[a, r]): b \ ef + r Source

Applies f to a start value s and all elements in a going from left to right.

That is, the result is of the form: f(...f(f(s, a[0]), a[1])..., xn).

def foldLeft2(f: c -> (a -> (b -> c \ ef)), c: c, a: Array[a, r1], b: Array[b, r2]): c \ ef + r1 + r2 Source

Accumulates the result of applying f pairwise to the elements of a and b starting with the initial value c and going from left to right.

def foldMap(f: a -> b \ ef, arr: Array[a, r]): b \ ef + r with Monoid[b] Source

Returns the result of mapping each element and combining the results.

def foldRight(f: a -> (b -> b \ ef), s: b, arr: Array[a, r]): b \ ef + r Source

Applies f to a start value s and all elements in a going from right to left.

That is, the result is of the form: f(a[0], ...f(a[n-1], f(a[n], s))...).

def foldRight2(f: a -> (b -> (c -> c \ ef)), c: c, a: Array[a, r1], b: Array[b, r2]): c \ ef + r1 + r2 Source

Accumulates the result of applying f pairwise to the elements of a and b starting with the initial value c and going from right to left.

def foldRightWithCont(f: a -> ((Unit -> b \ ef + r) -> b \ ef + r), z: b, arr: Array[a, r]): b \ ef + r Source

Applies f to a start value z and all elements in a going from right to left.

That is, the result is of the form: f(a[0], ...f(a[n-1], f(a[n], z))...). A foldRightWithCont allows early termination by not calling the continuation.

def forAll(f: a -> Bool \ ef, arr: Array[a, r]): Bool \ ef + r Source

Returns true if and only if all elements in arr satisfy the predicate f.

Returns true if arr is empty.

def forEach(f: a -> Unit \ ef, a: Array[a, r]): Unit \ ef + r Source

Apply the effectful function f to all the elements in the array a.

def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), a: Array[a, r]): Unit \ ef + r Source

Apply the effectful function f to all the elements in the array a.

def get(i: Int32, a: Array[a, r]): a \ r Source

Retrieves the value at position i in the array a.

def groupBy(rc1: Region[r1], f: a -> (a -> Bool), a: Array[a, r2]): Array[Array[a, r1], r1] \ r2 + r1 Source

Partitions a into subarrays such that for any two elements x and y in a subarray, f(x, y) is true.

A subarray is created by iterating through the remaining elements of a from left to right and adding an element to the subarray if and only if doing so creates no conflicts with the elements already in the subarray.

The function f must be pure.

def head(a: Array[a, r]): Option[a] \ r Source

Returns Some(x) if x is the first element of a.

Returns None if a is empty.

def indexOf(x: a, a: Array[a, r]): Option[Int32] \ r with Eq[a] Source

Alias for IndexOfLeft

def indexOfLeft(a: a, arr: Array[a, r]): Option[Int32] \ r with Eq[a] Source

Optionally returns the position of the first occurrence of a in arr searching from left to right.

def indexOfRight(a: a, arr: Array[a, r]): Option[Int32] \ r with Eq[a] Source

Optionally returns the position of the first occurrence of a in arr searching from right to left.

def indices(rc: Region[r], a: a, arr: Array[a, r]): Array[Int32, r] \ r with Eq[a] Source

Return the positions of the all the occurrences of a in arr.

def init(rc: Region[r], f: Int32 -> a \ ef, len: Int32): Array[a, r] \ ef + r Source

Build an array of length len by applying f to the successive indices.

def intercalate(rc1: Region[r1], sep: Array[a, r], arrs: Array[Array[a, r], r]): Array[a, r1] \ r + r1 Source

Returns the concatenation of the elements in arrs with the elements of sep inserted between every two adjacent elements.

def intersperse(rc1: Region[r1], x: a, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a with x inserted between every two adjacent elements.

def isEmpty(a: Array[a, r]): Bool Source

Returns true if the given array a is empty.

def isInfixOf(a1: Array[a, r1], a2: Array[a, r2]): Bool \ r1 + r2 with Eq[a] Source

Returns true if and only if a1 is a infix of a2.

def isPrefixOf(a1: Array[a, r1], a2: Array[a, r2]): Bool \ r1 + r2 with Eq[a] Source

Returns true if and only if a1 is a prefix of a2.

def isSuffixOf(a1: Array[a, r1], a2: Array[a, r2]): Bool \ r1 + r2 with Eq[a] Source

Returns true if and only if a1 is a suffix of a2.

def iterator(rc: Region[r1], a: Array[a, r2]): Iterator[a, r1 + r2, r1] \ r1 Source

Returns an iterator over a

Modifying a while using an iterator has undefined behavior and is dangerous.

def join(sep: String, a: Array[a, r]): String \ r with ToString[a] Source

Returns the concatenation of the string representation of each element in a with sep inserted between each element.

def joinWith(f: a -> String \ ef, sep: String, a: Array[a, r]): String \ ef + r Source

Returns the concatenation of the string representation of each element in a according to f with sep inserted between each element.

def last(a: Array[a, r]): Option[a] \ r Source

Returns Some(x) if x is the last element of a.

Returns None if a is empty.

def length(a: Array[a, r]): Int32 Source

Returns the length of the array a.

def map(rc1: Region[r1], f: a -> b \ ef, a: Array[a, r]): Array[b, r1] \ ef + r + r1 Source

Returns the result of applying f to every element in a.

The result is an empty array.

def mapWithIndex(rc1: Region[r1], f: Int32 -> (a -> b \ ef), a: Array[a, r]): Array[b, r1] \ ef + r + r1 Source

Returns the result of applying f to every element in a along with that element's index.

That is, the result is of the form: [ f(a[0], 0), f(a[1], 1), ... ].

def maximum(a: Array[a, r]): Option[a] \ r with Order[a] Source

Optionally finds the largest element of a according to the Order on a.

Returns None if a is empty.

def maximumBy(cmp: a -> (a -> Comparison), a: Array[a, r]): Option[a] \ r Source

Optionally finds the largest element of a according to the given comparator cmp.

Returns None if a is empty.

def memberOf(x: a, a: Array[a, r]): Bool \ r with Eq[a] Source

Returns true if and only if a contains the element x.

def minimum(a: Array[a, r]): Option[a] \ r with Order[a] Source

Optionally finds the smallest element of a according to the Order on a.

Returns None if a is empty.

def minimumBy(cmp: a -> (a -> Comparison), a: Array[a, r]): Option[a] \ r Source

Optionally finds the smallest element of a according to the given comparator cmp.

Returns None if a is empty.

def nth(i: Int32, a: Array[a, r]): Option[a] \ r Source

Optionally returns the element at position i in the array a.

def partition(rc1: Region[r1], rc2: Region[r2], f: a -> Bool \ ef, a: Array[a, r]): (Array[a, r1], Array[a, r2]) \ ef + r + r1 + r2 Source

Returns a pair of arrays (a1, a2).

a1 contains all elements of a that satisfy the predicate f. a2 contains all elements of a that do not satisfy the predicate f.

def patch(rc3: Region[r3], i: Int32, n: Int32, a: Array[a, r1], b: Array[a, r2]): Array[a, r3] \ r1 + r2 + r3 Source

Returns b with the n elements starting at index i replaced with the elements of a.

If any of the indices i, i+1, i+2, ... , i+n-1 are out of range in b then no patching is done at these indices. If a becomes depleted then no further patching is done. If patching occurs at index i+j in b, then the element at index j in a is used.

def patch!(i: Int32, n: Int32, a: Array[a, r1], b: Array[a, r2]): Unit \ r1 + r2 Source

Update the mutable array b replacing n elements starting at index i with the corresponding elements of array a.

If any of the indices i, i+1, i+2, ... , i+n-1 are out of range in b then no patching is done at these indices. If a becomes depleted then no further patching is done. If patching occurs at index i+j in b, then the element at index j in a is used.

def put(x: a, i: Int32, a: Array[a, r]): Unit \ r Source

Stores the value x at position i in the array a.

def range(rc: Region[r], b: Int32, e: Int32): Array[Int32, r] \ r Source

Returns an array of all integers between b (inclusive) and e (exclusive).

Returns [] if b >= e.

def reduceLeft(f: a -> (a -> a \ ef), a: Array[a, r]): Option[a] \ ef + r Source

Applies f to all elements in a going from left to right until a single value v is obtained. Returns Some(v).

Returns None if a is empty.

def reduceRight(f: a -> (a -> a \ ef), arr: Array[a, r]): Option[a] \ ef + r Source

Applies f to all elements in arr going from right to left until a single value v is obtained. Returns Some(v).

Returns None if arr is empty.

def repeat(rc: Region[r], n: Int32, x: a): Array[a, r] \ r Source

Returns an array with the element x repeated n times.

Returns the empty array if n <= 0.

def replace(rc1: Region[r1], from: { from = a }, to: { to = a }, a: Array[a, r]): Array[a, r1] \ r + r1 with Eq[a] Source

Returns a copy of a with every occurrence of from replaced by to.

def replace!(from: { from = a }, to: { to = a }, a: Array[a, r]): Unit \ r with Eq[a] Source

Replace every occurrence of from by to in the array a, mutating it in place.

def reverse(rc1: Region[r1], a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns the reverse of a.

def reverse!(arr: Array[a, r]): Unit \ r Source

Reverse the array arr, mutating it in place.

def rotateLeft(rc2: Region[r2], n: Int32, arr: Array[a, r1]): Array[a, r2] \ r1 + r2 Source

Rotate the contents of array arr by n steps to the left.

def rotateRight(rc2: Region[r2], n: Int32, arr: Array[a, r1]): Array[a, r2] \ r1 + r2 Source

Rotate the contents of array arr by n steps to the right.

def sameElements(a: Array[a, r1], b: Array[a, r2]): Bool \ r1 + r2 with Eq[a] Source

Returns true if arrays a and b have the same elements in the same order, i.e. are structurally equal.

def scan(rc: Region[r], f: b -> (a -> b \ ef), s: b, arr: Array[a, r]): Array[b, r] \ ef + r Source

Alias for scanLeft.

def scanLeft(rc: Region[r], f: b -> (a -> b \ ef), s: b, arr: Array[a, r]): Array[b, r] \ ef + r Source

Accumulates the result of applying f to arr going left to right.

That is, the result is of the form: [s , f(s, x1), f(f(s, x1), x2), ...].

def scanRight(rc: Region[r], f: a -> (b -> b \ ef), s: b, a: Array[a, r]): Array[b, r] \ ef + r Source

Accumulates the result of applying f to xs going right to left.

That is, the result is of the form: [..., f(xn-1, f(xn, s)), f(xn, s), s].

def shuffle(rnd: Random, a: Array[a, r]): Unit \ r + IO Source

Shuffles a using the Fisher–Yates shuffle.

def slice(rc1: Region[r1], start: { start = Int32 }, end: { end = Int32 }, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a fresh array with the elements from the array a from index start (inclusive) until index end (exclusive).

def sort(rc1: Region[r1], a: Array[a, r]): Array[a, r1] \ r + r1 with Order[a] Source

Returns a sorted copy of array a, where the 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 a.

The sort implementation is a Quicksort.

def sort!(a: Array[a, r]): Unit \ r with Order[a] Source

Sort array a so that elements are ordered from low to high according to their Order instance. The array is mutated in-place.

The sort is not stable, i.e., equal elements may appear in a different order than in the input a.

The sort implementation is a Quicksort.

def sortBy(rc1: Region[r1], f: a -> b, a: Array[a, r]): Array[a, r1] \ r + r1 with Order[b] Source

Returns a sorted copy of array a, where the 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 a.

The sort implementation is a Quicksort.

def sortBy!(f: a -> b, a: Array[a, r]): Unit \ r with Order[b] Source

Sort array a 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 array is mutated in-place.

The sort is not stable, i.e., equal elements may appear in a different order than in the input a.

The sort implementation is a Quicksort.

def sortWith(rc1: Region[r1], cmp: a -> (a -> Comparison), a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a sorted copy of array a, where the 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 a.

The sort implementation is a Quicksort.

def sortWith!(cmp: a -> (a -> Comparison), a: Array[a, r]): Unit \ r Source

Sort array a so that elements are ordered from low to high according to the comparison function cmp. The array is mutated in-place.

The sort is not stable, i.e., equal elements may appear in a different order than in the input a.

The sort implementation is a Quicksort.

def sortWithin!(cmp: a -> (a -> Comparison), lo: Int32, hi: Int32, a: Array[a, r]): Unit \ r Source

Sort array a between the indices lo and hi (both inclusive) so that elements in that range are ordered from low to high according to the comparison function cmp. The array is mutated in-place where elements outside the specified range are not changed. If lo >= hi, this does nothing.

The sort is not stable, i.e., equal elements may appear in a different order than in the input a.

The sort implementation is a Quicksort.

def span(rc1: Region[r1], rc2: Region[r2], f: a -> Bool \ ef, a: Array[a, r]): (Array[a, r1], Array[a, r2]) \ ef + r + r1 + r2 Source

Returns a pair of arrays (a1, a2).

a1 is the longest prefix of a that satisfies the predicate f. a2 is the remainder of a.

def sum(a: Array[Int32, r]): Int32 \ r Source

Returns the sum of all elements in the array a.

def sumWith(f: a -> Int32 \ ef, a: Array[a, r]): Int32 \ ef + r Source

Returns the sum of all elements in the array a according to the function f.

def swap!(i: Int32, j: Int32, a: Array[a, r]): Unit \ r Source

Swap the elements at i and j (helper for sorting).

Precondition: i and j are within bounds.

def take(rc1: Region[r1], n: Int32, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Alias for takeLeft.

def takeLeft(rc1: Region[r1], n: Int32, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a fresh array taking first n elements of a.

Returns a if n > length(xs).

def takeRight(rc1: Region[r1], n: Int32, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a fresh array taking last n elements of a.

Returns a if n > length(xs).

def takeWhile(rc1: Region[r1], f: a -> Bool \ ef, a: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Alias for takeWhileLeft.

def takeWhileLeft(rc1: Region[r1], f: a -> Bool \ ef, a: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Returns the longest prefix of a that satisfies the predicate f.

def takeWhileRight(rc1: Region[r1], f: a -> Bool \ ef, a: Array[a, r]): Array[a, r1] \ ef + r + r1 Source

Returns the longest suffix of a that satisfies the predicate f.

def toChain(arr: Array[a, r]): Chain[a] \ r Source

Returns the array arr as a chain.

def toDelayList(a: Array[a, r]): DelayList[a] \ r Source

Returns the array a as a DelayList.

def toList(a: Array[a, r]): List[a] \ r Source

Returns the array a as a list.

def toMap(a: Array[(a, b), r]): Map[a, b] \ r with Order[a] Source

Returns the association list xs as a map.

If xs contains multiple mappings with the same key, toMap does not make any guarantees about which mapping will be in the resulting map.

def toMutDeque(rc1: Region[r1], a: Array[a, r2]): MutDeque[a, r1] \ r2 + r1 Source

Returns a as a MutDeque.

def toMutList(rc1: Region[r1], a: Array[a, r2]): MutList[a, r1] \ r2 + r1 Source

Returns the array a as a MutList.

def toNec(arr: Array[a, r]): Option[Nec[a]] \ r Source

Optionally returns the array arr as a non-empty chain.

If arr is empty return None, otherwise return the Nec wrapped in Some.

def toNel(arr: Array[a, r]): Option[Nel[a]] \ r Source

Optionally returns the array arr as a non-empty list.

If arr is empty return None, otherwise return the Nel wrapped in Some.

def toSet(a: Array[a, r]): Set[a] \ r with Order[a] Source

Returns the array a as a set.

def toString(a: Array[a, r]): String \ r with ToString[a] Source

Returns a string representation of the given array a.

def toVector(a: Array[a, r]): Vector[a] \ r Source

Returns a as a Vector.

def transform!(f: a -> a \ ef, arr: Array[a, r]): Unit \ ef + r Source

Apply f to every element in array arr. Array arr is mutated.

def transformWithIndex!(f: Int32 -> (a -> a \ ef), arr: Array[a, r]): Unit \ ef + r Source

Apply f to every element in array a along with that element's index. Array a is mutated.

def transpose(rc3: Region[r3], a: Array[Array[a, r1], r2]): Array[Array[a, r3], r3] \ r1 + r2 + r3 Source

Returns the transpose of a.

Returns a if the dimensions of the elements of a are mismatched.

def unzip(rc1: Region[r1], rc2: Region[r2], a: Array[(a, b), r3]): (Array[a, r1], Array[b, r2]) \ r1 + r2 + r3 Source

Returns a pair of arrays, the first containing all first components in a and the second containing all second components in a.

def update(rc1: Region[r1], i: Int32, x: a, a: Array[a, r]): Array[a, r1] \ r + r1 Source

Returns a copy of a with the element at index i replaced by x.

Returns a shallow copy of a if i < 0 or i > length(xs)-1.

def updateSequence(rc3: Region[r3], i: Int32, sub: Array[a, r1], a: Array[a, r2]): Array[a, r3] \ r1 + r2 + r3 Source

Returns a copy of a with the elements starting at index i replaced by sub.

def updateSequence!(i: Int32, sub: Array[a, r1], a: Array[a, r2]): Unit \ r1 + r2 Source

Update the mutable array a with the elements starting at index i replaced by sub.

def zip(rc3: Region[r3], a: Array[a, r1], b: Array[b, r2]): Array[(a, b), r3] \ r1 + r2 + r3 Source

Returns an array where the element at index i is (x, y) where x is the element at index i in a and y is the element at index i in b.

If either a or b becomes depleted, then no further elements are added to the resulting array.

def zipWith(rc3: Region[r3], f: a -> (b -> c \ ef), a: Array[a, r1], b: Array[b, r2]): Array[c, r3] \ ef + r1 + r2 + r3 Source

Returns an array where the element at index i is f(x, y) where x is the element at index i in a and y is the element at index i in b.

If either a or b becomes depleted, then no further elements are added to the resulting array.