Iterator

enum Iterator[a: Type, ef: Eff, r: Eff]Source
case Iterator(Region[r], Unit -> Step[a] \ r + ef)

Definitions

def append(iter1: Iterator[a, ef1, r], iter2: Iterator[a, ef2, r]): Iterator[a, ef1 + ef2, r] Source

Returns iterB appended to (the end of) iterA.

Does not consume any elements from either iterator.

The original iterators iterA and iterB should not be reused.

def cons(x: a, iter: Iterator[a, ef, r]): Iterator[a, ef, r] \ r Source

Returns an iterator with the element x appended to the front of iterator iter.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def drop(n: Int32, iter: Iterator[a, ef, r]): Iterator[a, ef + r, r] \ r Source

Returns iter without the first n elements.

Returns an empty iterator if n is larger than the number of elements in iter. Returns iter if n < 0.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def dropWhile(f: a -> Bool \ ef2, iter: Iterator[a, ef1, r]): Iterator[a, r + ef1 + ef2, r] \ r Source

Returns iter without the longest prefix that satisfies the predicate f.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def empty(rc: Region[r]): Iterator[a, r, r] Source

Returns an empty iterator.

def enumerator(iter: Iterator[a, ef, r]): Iterator[(Int32, a), ef + r, r] \ r Source

Alias for zipWithIndex.

def filter(f: a -> Bool \ ef2, iter: Iterator[a, ef1, r]): Iterator[a, ef1 + ef2, r] Source

Returns an iterator with every element of the iterator iter that satisfies the predicate f.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def filterMap(f: a -> Option[b] \ ef2, iter: Iterator[a, ef1, r]): Iterator[b, ef1 + ef2, r] Source

Returns an iterator with every element of the iterator iter that produces Some(_) the from the function f.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def flatMap(f: a -> Iterator[b, ef2, r] \ ef3, ma: Iterator[a, ef1, r]): Iterator[b, ef3 + ef2 + r + ef1, r] \ r Source

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

Does not consume any elements from the iterator.

Currently f has to generate an iterator with region r.

def flatten(iter: Iterator[Iterator[a, ef1, r], ef2, r]): Iterator[a, r + ef1 + ef2, r] \ r Source

Returns the concatenation of the nested iterators in iter.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def foldLeft(f: b -> (a -> b \ ef2), s: b, iter: Iterator[a, ef1, r]): b \ ef1 + ef2 + r Source

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

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

Consumes the entire iterator.

def foldMap(f: a -> b \ ef2, iter: Iterator[a, ef1, r]): b \ ef1 + ef2 + r with Monoid[b] Source

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

def foldRight(f: a -> (b -> b \ ef2), s: b, iter: Iterator[a, ef1, r]): b \ ef1 + ef2 + r Source

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

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

Consumes the entire iterator.

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

Applies f to a start value z and all elements in iter 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.

Consumes the entire iterator.

def forEach(f: a -> Unit \ ef2, iter: Iterator[a, ef1, r]): Unit \ ef1 + ef2 + r Source

Applies f to every element of iter.

Consumes the entire iterator.

def forEachWithIndex(f: Int32 -> (a -> Unit \ ef2), iter: Iterator[a, ef1, r]): Unit \ ef1 + ef2 + r Source

Applies f to every element of iter along with that element's index.

Consumes the entire iterator.

def intercalate(sep: t[a], iter: Iterator[Iterator[a, ef, r], ef, r]): Iterator[a, ef + r, r] \ r with Foldable[t] Source

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

That is, returns b1 :: a1 ... an :: b2 :: ... bn-1 :: a1 :: ... :: an :: bn :: Nil.

Does not consume any elements from either iterator.

The original iterators sep and iter should not be reused.

def intersperse(sep: a, iter: Iterator[a, ef, r]): Iterator[a, ef + r, r] \ r Source

Returns an iterator with a inserted between every of iter.

Does not consume any elements from the iterator.

def iterate(rc: Region[r], f: Unit -> Option[a] \ ef): Iterator[a, ef, r] Source

Returns an iterator built with the stepper function f.

def join(sep: String, iter: Iterator[a, ef, r]): String \ ef + r with ToString[a] Source

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

Consumes the entire iterator.

def joinWith(f: a -> String \ ef2, sep: String, iter: Iterator[a, ef1, r]): String \ ef1 + ef2 + r Source

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

Consumes the entire iterator.

def map(f: a -> b \ ef2, iter: Iterator[a, ef1, r]): Iterator[b, ef1 + ef2, r] Source

Returns an iterator with every f lazily applied to each element in iter.

Does not consume any elements from the iterator.

def mapWithIndex(f: Int32 -> (a -> b \ ef2), iter: Iterator[a, ef1, r]): Iterator[b, ef1 + ef2, r] \ r Source

Returns an iterator with every f lazily applied to each element in iter together with its index.

Does not consume any elements from the iterator.

def next(iter: Iterator[a, ef, r]): Option[a] \ ef + r Source

Returns Some(x) if iter is not empty. Returns None otherwise.

Consumes the head element of iter.

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

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

Returns an empty iterator if b >= e.

def reduceLeft(f: a -> (a -> a \ ef2), iter: Iterator[a, ef1, r]): Option[a] \ ef1 + ef2 + r Source

Applies f to all elements in iter 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 iter is empty.

Consumes the entire iterator.

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

Returns an iterator over an iterable with the element x repeated n times.

Returns an empty iterator if n < 0.

def replace(from: { from = a }, to: { to = a }, iter: Iterator[a, ef, r]): Iterator[a, ef, r] with Eq[a] Source

Returns an iterator with every occurrence of from replaced by to in iter.

Does not consume any elements from the iterator.

def singleton(rc: Region[r], x: a): Iterator[a, r, r] \ r Source

Returns an iterator containing only a single element, x.

def sum(iter: Iterator[Int32, ef, r]): Int32 \ ef + r Source

Returns the sum of all elements in the iterator iter.

Consumes the entire iterator.

def sumWith(f: a -> Int32 \ ef2, iter: Iterator[a, ef1, r]): Int32 \ ef1 + ef2 + r Source

Returns the sum of all elements in the iterator iter according to the function f.

Consumes the entire iterator.

def take(n: Int32, iter: Iterator[a, ef, r]): Iterator[a, ef + r, r] \ r Source

Returns iter with the first n elements.

Returns iter if n is larger than the number of elements in iter. Returns an empty iterator if n < 0.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

def takeWhile(f: a -> Bool \ ef2, iter: Iterator[a, ef1, r]): Iterator[a, ef1 + ef2, r] Source

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

Does not consume any elements from the iterator.

The original iterator iter should not be reused.

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

Returns the contents of iter as an array.

Consumes the entire iterator.

def toChain(iter: Iterator[a, ef, r]): Chain[a] \ ef + r Source

Returns the contents of iter as a chain.

Consumes the entire iterator.

def toList(iter: Iterator[a, ef, r]): List[a] \ ef + r Source

Returns the contents of iter as a list.

Consumes the entire iterator.

def toMap(iter: Iterator[(k, v), ef, r]): Map[k, v] \ ef + r with Order[k] Source

Returns the contents of iter as a map.

Consumes the entire iterator.

def toMutDeque(rc: Region[r1], iter: Iterator[a, ef, r2]): MutDeque[a, r1] \ ef + r2 + r1 Source

Returns the contents of iter as a MutDeque.

Consumes the entire iterator.

def toNec(iter: Iterator[a, ef, r]): Option[Nec[a]] \ ef + r Source

Returns the contents of iter as a Nec.

Consumes the entire iterator.

def toNel(iter: Iterator[a, ef, r]): Option[Nel[a]] \ ef + r Source

Returns the contents of iter as a Some(Nel) if iter is not empty. Returns None otherwise.

Consumes the entire iterator.

def toSet(iter: Iterator[a, ef, r]): Set[a] \ ef + r with Order[a] Source

Returns the contents of iter as a set. Consumes the entire iterator.

def toVector(iter: Iterator[a, ef, r]): Vector[a] \ ef + r Source

Returns the contents of iter as an array.

Consumes the entire iterator.

def unfoldWithOk(rc: Region[r], f: Unit -> Result[e, a] \ ef): Iterator[a, ef, r] Source

Returns an iterator over the results of f.

If f returns Ok(x), then the next element is x.

If f returns Err(e), then the iterator is depleted.

def zip(iterA: Iterator[a, ef1, r1], iterB: Iterator[b, ef2, r2]): Iterator[(a, b), r2 + ef1 + ef2, r1] Source

Returns an iterator where the element at index i is (a, b) where a is the element at index i in iterA and b is the element at index i in iterB.

Does not consume any elements from either iterator.

If either iterA or iterB is depleted, then no further elements are added to the resulting iterator.

The original iterators iterA and iterB should not be reused.

An iterator should never be zipped with itself.

def zipWith(f: a -> (b -> c \ ef3), iterA: Iterator[a, ef1, r1], iterB: Iterator[b, ef2, r2]): Iterator[c, ef3 + ef1 + ef2 + r2, r1] Source

Returns an iterator where the element at index i is f(a, b) where a is the element at index i in iterA and b is the element at index i in iterB.

Does not consume any elements from either iterator.

If either iterA or iterB becomes depleted, then no further elements are added to the resulting list.

The original iterators iterA and iterB should not be reused.

An iterator should never be zipped with itself.

def zipWithIndex(iter: Iterator[a, ef, r]): Iterator[(Int32, a), ef + r, r] \ r Source

Returns an iterator where the element at index i is (a, i) where a is the element at index i in iter.

Does not consume any elements from the iterator.

The original iterator iter should not be reused.