flix

0.54.0

Vector

Definitions

def ap(f: Vector[a -> b \ ef], v: Vector[a]): Vector[b] \ ef Source

Apply every function from f to every argument from v 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(v1: Vector[a], v2: Vector[a]): Vector[a] Source

Return a new vector, appending the elements v2 after elements of v1.

def compare(a: Vector[a], b: Vector[a]): Comparison with Order[a] Source

Compares a and b lexicographically.

def count(f: a -> Bool \ ef, v: Vector[a]): Int32 \ ef Source

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

def drop(n: Int32, v: Vector[a]): Vector[a] Source

Alias for dropLeft.

def dropLeft(n: Int32, v: Vector[a]): Vector[a] Source

Returns a copy of vector v, dropping the first n elements.

Returns an empty vector if n > length(v).

def dropRight(n: Int32, v: Vector[a]): Vector[a] Source

Returns a copy of vector v, dropping the last n elements.

Returns an empty vector if n > length(v).

def dropWhile(f: a -> Bool \ ef, v: Vector[a]): Vector[a] \ ef Source

Alias for dropWhileLeft.

def dropWhileLeft(f: a -> Bool \ ef, v: Vector[a]): Vector[a] \ ef Source

Returns copy of vector v without the longest prefix that satisfies the predicate f.

def dropWhileRight(f: a -> Bool \ ef, v: Vector[a]): Vector[a] \ ef Source

Returns copy of vector v without the longest suffix that satisfies the predicate f.

def empty(): Vector[a] Source

Returns an empty (length zero) vector.

def enumerator(rc: Region[r], v: Vector[a]): Iterator[(Int32, a), r, r] \ r Source

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

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

def equals(a: Vector[a], b: Vector[a]): Bool 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 exists(f: a -> Bool \ ef, v: Vector[a]): Bool \ ef Source

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

Returns false if v is empty.

def filter(f: a -> Bool \ ef, v: Vector[a]): Vector[a] \ ef Source

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

def filterMap(f: a -> Option[b] \ ef, v: Vector[a]): Vector[b] \ ef Source

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

def find(f: a -> Bool \ ef, v: Vector[a]): Option[a] \ ef Source

Alias for findLeft.

def findIndexOf(f: a -> Bool \ ef, v: Vector[a]): Option[Int32] \ ef Source

Alias for findIndexOfLeft.

def findIndexOfLeft(f: a -> Bool \ ef, v: Vector[a]): Option[Int32] \ ef Source

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

def findIndexOfRight(f: a -> Bool \ ef, v: Vector[a]): Option[Int32] \ ef Source

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

def findIndices(f: a -> Bool \ ef, v: Vector[a]): Vector[Int32] \ ef Source

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

def findLeft(f: a -> Bool \ ef, v: Vector[a]): Option[a] \ ef Source

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

def findMap(f: a -> Option[b] \ ef, v: Vector[a]): Option[b] \ ef Source

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

Returns None if every element of xs is None.

def findRight(f: a -> Bool \ ef, v: Vector[a]): Option[a] \ ef Source

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

def flatMap(f: a -> Vector[b] \ ef, v: Vector[a]): Vector[b] \ ef Source

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

def flatten(vs: Vector[Vector[a]]): Vector[a] Source

Returns the concatenation of all the vectors in the vector vs.

def fold(v: Vector[a]): a with Monoid[a] Source

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

def fold2(f: c -> (a -> (b -> c \ ef)), c: c, a: Vector[a], b: Vector[b]): c \ ef Source

Alias for foldLeft2.

def foldLeft(f: b -> (a -> b \ ef), s: b, v: Vector[a]): b \ ef Source

Applies f to a start value s and all elements in v 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: Vector[a], b: Vector[b]): c \ ef 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, v: Vector[a]): b \ ef with Monoid[b] Source

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

def foldRight(f: a -> (b -> b \ ef), s: b, v: Vector[a]): b \ ef Source

Applies f to a start value s and all elements in v 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: Vector[a], b: Vector[b]): c \ ef 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) -> b \ ef), z: b, v: Vector[a]): b \ ef Source

Applies f to a start value z and all elements in v 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, v: Vector[a]): Bool \ ef Source

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

Returns true if v is empty.

def forEach(f: a -> Unit \ ef, v: Vector[a]): Unit \ ef Source

Apply the effectful function f to all the elements in the vector v.

def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), v: Vector[a]): Unit \ ef Source

Apply the effectful function f to all the elements in the vector v.

def get(i: Int32, v: Vector[a]): a Source

Retrieves the value at position i in the vector v.

def groupBy(f: a -> (a -> Bool), v: Vector[a]): Vector[Vector[a]] Source

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

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

The function f must be pure.

def head(v: Vector[a]): Option[a] Source

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

Returns None if v is empty.

def indexOf(x: a, v: Vector[a]): Option[Int32] with Eq[a] Source

Alias for IndexOfLeft

def indexOfLeft(a: a, v: Vector[a]): Option[Int32] with Eq[a] Source

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

def indexOfRight(a: a, v: Vector[a]): Option[Int32] with Eq[a] Source

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

def indices(a: a, v: Vector[a]): Vector[Int32] with Eq[a] Source

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

def init(f: Int32 -> a \ ef, len: Int32): Vector[a] \ ef Source

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

def intercalate(sep: Vector[a], vs: Vector[Vector[a]]): Vector[a] Source

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

def intersperse(sep: a, v: Vector[a]): Vector[a] Source

Returns a copy of v with sep inserted between every two adjacent elements.

def isEmpty(v: Vector[a]): Bool Source

Returns true if the given vector v is empty.

def isInfixOf(a: Vector[a], b: Vector[a]): Bool with Eq[a] Source

Returns true if and only if a is a infix of b.

def isPrefixOf(a: Vector[a], b: Vector[a]): Bool with Eq[a] Source

Returns true if and only if a is a prefix of b.

def isSuffixOf(a: Vector[a], b: Vector[a]): Bool with Eq[a] Source

Returns true if and only if a is a suffix of b.

def iterator(rc: Region[r], v: Vector[a]): Iterator[a, r, r] \ r Source

Returns an iterator over v

def join(sep: String, v: Vector[a]): String with ToString[a] Source

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

def joinWith(f: a -> String \ ef, sep: String, v: Vector[a]): String \ ef Source

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

def last(v: Vector[a]): Option[a] Source

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

Returns None if v is empty.

def length(v: Vector[a]): Int32 Source

Returns the number of elements in the vector v.

def map(f: a -> b \ ef, v: Vector[a]): Vector[b] \ ef Source

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

The result is a new vector.

def mapWithIndex(f: Int32 -> (a -> b \ ef), v: Vector[a]): Vector[b] \ ef Source

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

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

def maximum(v: Vector[a]): Option[a] with Order[a] Source

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

Returns None if v is empty.

def maximumBy(cmp: a -> (a -> Comparison), v: Vector[a]): Option[a] Source

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

Returns None if v is empty.

def memberOf(x: a, v: Vector[a]): Bool with Eq[a] Source

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

def minimum(v: Vector[a]): Option[a] with Order[a] Source

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

Returns None if v is empty.

def minimumBy(cmp: a -> (a -> Comparison), v: Vector[a]): Option[a] Source

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

Returns None if v is empty.

def nonEmpty(v: Vector[a]): Bool Source

Returns true if the given vector v is non-empty.

def nth(i: Int32, v: Vector[a]): Option[a] Source

Optionally returns the element at position i in the vector v.

def partition(f: a -> Bool \ ef, v: Vector[a]): (Vector[a], Vector[a]) \ ef Source

Returns a pair of vectors (v1, v2).

v1 contains all elements of v that satisfy the predicate f. v2 contains all elements of v that do not satisfy the predicate f.

def patch(i: Int32, n: Int32, a: Vector[a], b: Vector[a]): Vector[a] 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 range(b: Int32, e: Int32): Vector[Int32] Source

Returns a vector of all integers between b (inclusive) and e (exclusive).

Returns an empty vector if b >= e.

def reduceLeft(f: a -> (a -> a \ ef), v: Vector[a]): Option[a] \ ef Source

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

Returns None if v is empty.

def reduceRight(f: a -> (a -> a \ ef), v: Vector[a]): Option[a] \ ef Source

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

Returns None if v is empty.

def repeat(n: Int32, x: a): Vector[a] Source

Returns a vector with the element x repeated n times.

Returns an empty vector if n <= 0.

def replace(src: { src = a }, dst: { dst = a }, v: Vector[a]): Vector[a] with Eq[a] Source

Returns a copy of v with every occurrence of src replaced by dst.

def reverse(v: Vector[a]): Vector[a] Source

Returns the reverse of v.

def rotateLeft(n: Int32, v: Vector[a]): Vector[a] Source

Rotate the contents of vector v by n steps to the left.

def rotateRight(n: Int32, v: Vector[a]): Vector[a] Source

Rotate the contents of vector v by n steps to the right.

def scan(f: b -> (a -> b \ ef), s: b, v: Vector[a]): Vector[b] \ ef Source

Alias for scanLeft.

def scanLeft(f: b -> (a -> b \ ef), s: b, v: Vector[a]): Vector[b] \ ef Source

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

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

def scanRight(f: a -> (b -> b \ ef), s: b, v: Vector[a]): Vector[b] \ ef 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 sequence(v: Vector[m[a]]): m[Vector[a]] with Applicative[m] Source

Returns the result of running all the actions in the list v going from left to right.

def shuffle(v: Vector[a]): Vector[a] \ NonDet Source

Shuffles v using the Fisher–Yates shuffle.

def singleton(x: a): Vector[a] Source

Returns a singleton vector containing x`.

def size(v: Vector[a]): Int32 Source

Returns the number of elements in the vector v.

def slice(start: { start = Int32 }, end: { end = Int32 }, v: Vector[a]): Vector[a] Source

Returns a fresh array with the elements from the vector v from index b (inclusive) until index e (exclusive).

def sort(v: Vector[a]): Vector[a] with Order[a] Source

Returns a sorted copy of vector v, 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 v.

The sort implementation is a Quicksort.

def sortBy(f: a -> b, v: Vector[a]): Vector[a] with Order[b] Source

Returns a sorted copy of vector v, 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 v.

The sort implementation is a Quicksort.

def sortWith(cmp: a -> (a -> Comparison), v: Vector[a]): Vector[a] Source

Returns a sorted copy of vector v, 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 v.

The sort implementation is a Quicksort.

def span(f: a -> Bool \ ef, v: Vector[a]): (Vector[a], Vector[a]) \ ef Source

Returns a pair of vectors (v1, v2).

v1 is the longest prefix of v that satisfies the predicate f. v2 is the remainder of v.

def splitAt(n: Int32, v: Vector[a]): (Vector[a], Vector[a]) Source

Split the vector v at the position n returning the left and right parts. Position n is included in the right part.

Example: splitAt(2, Vector#{1, 2, 3, 4}) returns (Vector#{1, 2}, Vector#{3, 4})

Returns (v, Vector#{}) if n > length(xs). Returns (Vector#{}, v) if n < 0.

def sum(v: Vector[Int32]): Int32 Source

Returns the sum of all elements in the vector v.

def sumWith(f: a -> Int32 \ ef, v: Vector[a]): Int32 \ ef Source

Returns the sum of all elements in the vector v according to the function f.

def take(n: Int32, v: Vector[a]): Vector[a] Source

Alias for takeLeft.

def takeLeft(n: Int32, v: Vector[a]): Vector[a] Source

Returns a fresh vector taking first n elements of v.

Returns a copy of v if n > length(v).

def takeRight(n: Int32, v: Vector[a]): Vector[a] Source

Returns a fresh vector taking last n elements of v.

Returns a copy v if n > length(v).

def takeWhile(f: a -> Bool \ ef, a: Vector[a]): Vector[a] \ ef Source

Alias for takeWhileLeft.

def takeWhileLeft(f: a -> Bool \ ef, v: Vector[a]): Vector[a] \ ef Source

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

def takeWhileRight(f: a -> Bool \ ef, v: Vector[a]): Vector[a] \ ef Source

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

def toArray(rc: Region[r], v: Vector[a]): Array[a, r] \ r Source

Returns the vector v as an array.

def toChain(v: Vector[a]): Chain[a] Source

Returns the vector v as a chain.

def toDelayList(v: Vector[a]): DelayList[a] Source

Returns the vector v as a DelayList.

def toList(v: Vector[a]): List[a] Source

Returns the vector v as a list.

def toMap(v: Vector[(a, b)]): Map[a, b] with Order[a] Source

Returns the association vector v as a map.

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

def toMutDeque(rc: Region[r], v: Vector[a]): MutDeque[a, r] \ r Source

Returns v as a MutDeque.

def toMutList(rc: Region[r], v: Vector[a]): MutList[a, r] \ r Source

Returns the array a as a MutList.

def toNec(v: Vector[a]): Option[Nec[a]] Source

Optionally returns the vector v as a non-empty chain.

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

def toNel(v: Vector[a]): Option[Nel[a]] Source

Optionally returns the vector v as a non-empty list.

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

def toSet(v: Vector[a]): Set[a] with Order[a] Source

Returns the vector v as a set.

def toString(v: Vector[a]): String with ToString[a] Source

Returns a string representation of the given vector v.

def transpose(vs: Vector[Vector[a]]): Vector[Vector[a]] Source

Returns the transpose of vs.

Returns a non-transposed copy of vs if the dimensions of the elements of vs are mismatched.

def traverse(f: a -> m[b] \ ef, v: Vector[a]): m[Vector[b]] \ ef with Applicative[m] Source

Returns the result of applying the applicative mapping function f to all the elements of the vector v going from left to right.

def unzip(v: Vector[(a, b)]): (Vector[a], Vector[b]) Source

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

def update(i: Int32, x: a, v: Vector[a]): Vector[a] Source

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

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

def updateSequence(i: Int32, sub: Vector[a], v: Vector[a]): Vector[a] Source

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

def zip(a: Vector[a], b: Vector[b]): Vector[(a, b)] Source

Returns a vector 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 vector.

def zipWith(f: a -> (b -> c \ ef), a: Vector[a], b: Vector[b]): Vector[c] \ ef Source

Returns a vector 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 vector.

def zipWithA(f: a -> (b -> m[c] \ ef), v1: Vector[a], v2: Vector[b]): m[Vector[c]] \ ef with Applicative[m] Source

Generalize zipWith to an applicative functor f.