DelayList

Definitions

@Experimental @LazyWhenPure def ap(f: DelayList[a -> b \ ef], l: DelayList[a]): DelayList[b] \ efSource

Apply every function from f to every argument from l and return a list with all results. For f = f1, f2, ... and l = x1, x2, ... the results appear in the order f1(x1), f1(x2), ..., f2(x1), f2(x2), ....

Whether the i-th function in f (fi) is applied eagerly or lazily depends on its purity:

  • If fi is pure then it is applied lazily (i.e. the tail of l is not forced).
  • If fi is impure then it is applied eagerly (i.e. the entire list l is forced).

Note that this implies that ALL functions in f must be pure to avoid forcing l.

@Experimental @Lazy def append(l1: DelayList[a], l2: DelayList[a]): DelayList[a]Source

Returns l2 appended to l1.

Does not force the tail of l1.

@Experimental def count(f: a -> Bool \ ef, l: DelayList[a]): Int32 \ efSource

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

Forces the entire list l.

@Experimental @Lazy def drop(n: Int32, l: DelayList[a]): DelayList[a]Source

Returns l without the first n elements.

Returns ENil if n > length(l). Returns l if n < 1.

Does not force the tail of l.

@Experimental @LazyWhenPure def dropWhile(f: a -> Bool \ ef, l: DelayList[a]): DelayList[a] \ efSource

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

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the tail is forced until the first element that satisfies f).
@Experimental def empty(_unit: Unit): DelayList[a]Source

Returns an empty DelayList.

def enumerator(rc: Region[r], l: DelayList[a]): Iterator[(Int32, a), r, r] \ rSource

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

@Experimental def exists(f: a -> Bool \ ef, l: DelayList[a]): Bool \ efSource

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

Returns false if l is empty.

Forces elements of l until the predicate f is satisfied.

@Experimental @LazyWhenPure def filter(f: a -> Bool \ ef, l: DelayList[a]): DelayList[a] \ efSource

Returns a DelayList with every element in l that satisfies the predicate f.

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the entire list l is forced).
@Experimental @LazyWhenPure def filterMap(f: a -> Option[b] \ ef, l: DelayList[a]): DelayList[b] \ efSource

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

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the entire list l is forced).
@Experimental def findLeft(f: a -> Bool \ ef, l: DelayList[a]): Option[a] \ efSource

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

Forces elements of l until the predicate f is satisfied.

@Experimental def findMap(f: a -> Option[b] \ ef, l: DelayList[a]): Option[b] \ efSource

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

Returns None if every element f(x) of l is None.

Forces elements of l until f(x) returns Some(v).

@Experimental def findRight(f: a -> Bool \ ef, l: DelayList[a]): Option[a] \ efSource

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

Forces the entire list l.

@Experimental @LazyWhenPure def flatMap(f: a -> DelayList[b] \ ef, l: DelayList[a]): DelayList[b] \ efSource

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

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the entire list l is forced).
@Experimental @Lazy def flatten(l: DelayList[DelayList[a]]): DelayList[a]Source

Returns the concatenation of the elements in l.

Does not force the tail of l.

@Experimental def foldLeft(f: b -> (a -> b \ ef), s: b, l: DelayList[a]): b \ efSource

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).

Forces the entire list l.

def foldMap(f: a -> b \ ef, l: DelayList[a]): b \ efSource

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

@Experimental def foldRight(f: a -> (b -> b \ ef), s: b, l: DelayList[a]): b \ efSource

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))...).

Forces the entire list l.

@Experimental def foldRightWithCont(f: a -> ((Unit -> b \ ef) -> b \ ef), z: b, l: DelayList[a]): b \ efSource

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.

Calling the continuation forces the list l.

@Experimental def forAll(f: a -> Bool \ ef, l: DelayList[a]): Bool \ efSource

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

Returns true if l is empty.

Forces elements in l until the first element that does not satisfy the predicate f (inclusive).

@Experimental def forEach(f: a -> Unit \ ef, l: DelayList[a]): Unit \ efSource

Applies f to every element of l.

Forces the entire list l.

@Experimental def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), l: DelayList[a]): Unit \ efSource

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

Forces the entire list l.

@Experimental @Lazy def from(n: Int32): DelayList[Int32]Source

Returns an infinite sequence of integers starting from and including n.

@Experimental def head(l: DelayList[a]): Option[a]Source

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

Returns None if l is empty.

Does not force the tail of l.

@Experimental @Lazy def intercalate(l1: DelayList[a], l2: DelayList[DelayList[a]]): DelayList[a]Source

Returns the concatenation of the elements in l2 with the elements of l1 inserted between every two adjacent elements of l2.

That is, returns l2.1 :: l1.1 ... l1.n :: l2.2 :: ... :: l2.n-1 :: l1.1 :: ... :: l1.n :: l2.n :: ENil.

Does not force the tail of l2.

@Experimental @Lazy def intersperse(x: a, l: DelayList[a]): DelayList[a]Source

Returns l with x inserted between every two adjacent elements.

Does not force the tail of l.

@Experimental def isEmpty(l: DelayList[a]): BoolSource

Returns true if and only if l is the empty DelayList, i.e. ENil.

Does not force the tail of l.

@Experimental @Lazy def iterator(rc: Region[r], l: DelayList[a]): Iterator[a, r, r] \ rSource

Returns l as an Iterator.

Does not force any elements of the list.

@Experimental def join(sep: String, l: DelayList[a]): StringSource

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

Forces the entire list l.

@Experimental def joinWith(f: a -> String \ ef, sep: String, l: DelayList[a]): String \ efSource

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

Forces the entire list l.

@Experimental def last(l: DelayList[a]): Option[a]Source

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

Returns None if l is empty.

Forces the entire list l.

@Experimental def length(l: DelayList[a]): Int32Source

Returns the length of l.

Forces the entire list l.

@Experimental @LazyWhenPure def map(f: a -> b \ ef, l: DelayList[a]): DelayList[b] \ efSource

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

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the entire list l is forced).
@Experimental @LazyWhenPure def mapWithIndex(f: Int32 -> (a -> b \ ef), l: DelayList[a]): DelayList[b] \ efSource

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) :: ....

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the entire list l is forced).
@Experimental def maximum(l: DelayList[a]): Option[a]Source

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

Returns None if l is empty.

Forces the entire list l.

@Experimental def maximumBy(cmp: a -> (a -> Comparison), l: DelayList[a]): Option[a]Source

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

Returns None if l is empty.

Forces the entire list l.

@Experimental def memberOf(x: a, l: DelayList[a]): BoolSource

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

Forces elements until x is found.

@Experimental def minimum(l: DelayList[a]): Option[a]Source

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

Returns None if l is empty.

Forces the entire list l.

@Experimental def minimumBy(cmp: a -> (a -> Comparison), l: DelayList[a]): Option[a]Source

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

Returns None if l is empty.

Forces the entire list l.

@Experimental def partition(f: a -> Bool \ ef, l: DelayList[a]): (DelayList[a], DelayList[a]) \ efSource

Returns a pair of lists (l1, l2) where: - l1 contains all elements of l that satisfy the predicate f. - l2 contains all elements of l that DO NOT satisfy the predicate f.

Forces the entire list l.

@Experimental @Lazy def range(b: Int32, e: Int32): DelayList[Int32]Source

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

Returns an empty DelayList if b >= e.

@Experimental def reduceLeft(f: a -> (a -> a \ ef), l: DelayList[a]): Option[a] \ efSource

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.

Forces the entire list l.

@Experimental def reduceRight(f: a -> (a -> a \ ef), l: DelayList[a]): Option[a] \ efSource

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.

Forces the entire list l.

@Experimental @Lazy def repeat(x: a): DelayList[a]Source

Returns an infinite DelayList of repeating xs.

@Experimental @Lazy def replace(from: { from = a }, to: { to = a }, l: DelayList[a]): DelayList[a]Source

Returns l with every occurrence of from replaced by to.

Does not force the tail of l.

@Experimental @Lazy def reverse(l: DelayList[a]): DelayList[a]Source

Reverses the list l.

Does not force the tail of l.

@Experimental def sequence(l: DelayList[m[a]]): m[DelayList[a]]Source

Returns the result of running all the actions in the DelayList l.

def shuffle(rnd: Random, l: DelayList[a]): DelayList[a] \ IOSource

Shuffles l using the Fisher–Yates shuffle.

@Experimental def singleton(x: a): DelayList[a]Source

Return the singleton list with element x.

@Experimental @LazyWhenPure def span(f: a -> Bool \ ef, l: DelayList[a]): (DelayList[a], DelayList[a]) \ efSource

Returns a pair of lists (l1, l2) where: - l1 is the longest prefix of l that satisfies the predicate f. - l2 is the remainder of l.

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the entire list l is forced).
@Experimental def sum(l: DelayList[Int32]): Int32Source

Returns the sum of all elements in the DelayList l.

Forces the entire list l.

@Experimental def sumWith(f: a -> Int32 \ ef, l: DelayList[a]): Int32 \ efSource

Returns the sum of all elements in the DelayList l according to the function f.

Forces the entire list l.

@Experimental @Lazy def tail(l: DelayList[a]): DelayList[a]Source

Returns l without the first element.

Does not force the tail of l.

@Experimental @Lazy def take(n: Int32, l: DelayList[a]): DelayList[a]Source

Returns the first n elements of l.

Does not force the tail of l.

@Experimental @LazyWhenPure def takeWhile(f: a -> Bool \ ef, l: DelayList[a]): DelayList[a] \ efSource

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

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tail is not forced).
  • If f is impure then it is applied eagerly (i.e. the tail is forced until the first element that satisfies f).
@Experimental def toArray(rc: Region[r], l: DelayList[a]): Array[a, r] \ rSource

Returns l as an Array.

Forces the entire list l.

@Experimental def toList(l: DelayList[a]): List[a]Source

Returns l as a List.

Forces the entire list l.

@Experimental def toMap(l: DelayList[(a, b)]): Map[a, b]Source

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.

Forces the entire list l.

def toMutDeque(rc: Region[r], l: DelayList[a]): MutDeque[a, r] \ rSource

Returns l as a MutDeque.

@Experimental def toMutList(rc: Region[r], l: DelayList[a]): MutList[a, r] \ rSource

Returns l as a List.

Forces the entire list l.

@Experimental def toSet(l: DelayList[a]): Set[a]Source

Returns l as a Set.

Forces the entire list l.

@Experimental def toString(l: DelayList[a]): StringSource

Returns a string representation of l.

Forces the entire list l.

@Experimental def toVector(l: DelayList[a]): Vector[a]Source

Returns l as a Vector.

Forces the entire list l.

@Experimental def traverse(f: a -> m[b] \ ef, l: DelayList[a]): m[DelayList[b]] \ efSource

Returns the result of applying the applicative mapping function f to all the elements of the DelayList l.

@Experimental @Lazy def zip(l1: DelayList[a], l2: DelayList[b]): DelayList[(a, b)]Source

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 is depleted, then no further elements are added to the resulting list.

Does not force the tail of either l1 or l2.

@Experimental @LazyWhenPure def zipWith(f: a -> (b -> c \ ef), l1: DelayList[a], l2: DelayList[b]): DelayList[c] \ efSource

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 is depleted, then no further elements are added to the resulting list.

Whether f is applied eagerly or lazily depends on its purity:

  • If f is pure then it is applied lazily (i.e. the tails are not forced).
  • If f is impure then it is applied eagerly (i.e. both lists l1 and l2 are forced).
def zipWithIndex(l: DelayList[a]): DelayList[(Int32, a)]Source

Returns a DelayList where each element e is mapped to (i, e) where i is the index of e.

Does not force the tail of l.