Chain
enum Chain[t: Type]Sourcecase Emptycase One(t)case Chain(Chain[t], Chain[t])The Chain type.
A chain is a list represented as an unbalanced binary tree. It supports efficient append and "snoc" - appending elements at the tail of the list.
Note - the constructors Empty, One and Chain should not be used directly.
Instances
instance Applicative[Chain]Sourceinstance Collectable[Chain[a]]Sourceinstance Filterable[Chain]Sourceinstance Formattable[Chain[a]] with Formattable[a]Sourceinstance Traversable[Chain]Sourceinstance UnorderedFoldable[Chain]Sourceinstance Witherable[Chain]SourceDefinitions
Apply every function from f to every argument from x and return a chain 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), ....
Returns a new chain formed by appending the chains c1 and c2.
Compares chains c1 and c2 lexicographically.
Returns the number of elements in c that satisfy the predicate f.
Returns c without the first n elements.
Returns an empty chain if n > length(c).
Returns c if n < 0.
Returns c without the last n elements.
Returns an empty chain if n > length(c).
Returns c if n < 0.
Returns c without the longest prefix that satisfies the predicate f.
Returns c without the longest suffix that satisfies the predicate f.
Returns true if and only if c1 and c2 and equal.
Returns true if and only if at least one element in c satisfies the predicate f.
Returns false if c is empty.
Returns a chain of every element in c that satisfies the predicate f.
The function f must be pure.
Collects the results of applying the partial function f to every element in c.
Alias for findLeft.
The function f must be pure.
Optionally returns the first element of c that satisfies the predicate f when searching from left to right.
The function f must be pure.
Returns the first non-None result of applying the partial function f to each element of c.
Returns None if every element of c is None.
Optionally returns the first element of c that satisfies the predicate f when searching from right to left.
The function f must be pure.
Returns the result of applying f to every element in c and concatenating the results.
Applies f to a start value s and all elements in c going from left to right.
That is, the result is of the form: f(...f(f(s, x1), x2)..., xn).
Returns the result of mapping each element and combining the results.
Applies f to a start value s and all elements in c going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...).
Returns true if and only if all elements in c satisfy the predicate f.
Returns true if c is empty.
Applies f to every element of c along with that element's index.
Returns the element at position i in the chain c.
Throws IndexOutOfBoundsException if the index is out of bounds.
Returns Some(x) if x is the first element of c.
Returns None if c is empty.
Optionally returns the position of a in c.
Returns the positions of all occurrences of x in c.
Returns the subchain of c without the last element.
Returns None if the chain c is empty.
Returns c with a inserted between every two adjacent elements.
Returns the concatenation of the string representation
of each element in c with sep inserted between each element.
Returns the concatenation of the string representation
of each element in c according to f with sep inserted between each element.
Returns Some(x) if x is the last element of c.
Returns None if c is empty.
Returns the result of applying f to every element in c.
That is, the result is of the form: f(x1) :: f(x2) :: ....
mapAccumLeft is a stateful version of map. The accumulating parameter s is updated at each
step in a left-to-right traversal.
mapAccumRight is a stateful version of map. The accumulating parameter s is updated at each
step in a right-to-left traversal.
Returns the result of applying f to every element in c along with that element's index.
That is, the result is of the form: f(0, x0) :: f(1, x1) :: ....
Returns true if and only if c contains the element a.
Optionally returns the element at position i in the chain c.
Returns a list of all integers between b (inclusive) and e (exclusive).
Returns an empty chain if b >= e.
Returns a chain with the element a repeated n times.
Returns an empty chain if n < 0.
Accumulates the result of applying f to c going left to right.
That is, the result is of the form: s :: f(s, x1) :: f(f(s, x1), x2) ....
Accumulates the result of applying f to c going right to left.
That is, the result is of the form: ... f(xn-1, f(xn, s)) :: f(xn, s) :: s.
def sequence(c: Chain[m[a]]): m[Chain[a]] with Applicative[m]§ SourceReturns the result of running all the actions in the chain c.
Sort chain c 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 c.
The sort implementation is a Quicksort.
Sort chain c 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 c.
The sort implementation is a Quicksort.
Sort chain c 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 c.
The sort implementation is a Quicksort.
Returns the sum of all elements in the chain c according to the function f.
Returns the first n elements of c.
Returns c if n > length(c).
Returns an empty chain if n < 0.
Returns the last n elements of c.
Returns c if n > length(c).
Returns an empty chain if n < 0.
Returns the longest prefix of c that satisfies the predicate f.
Returns the longest suffix of c that satisfies the predicate f.
Returns the chain of pairs c that represents an association list as a map.
If c contains multiple mappings with the same key, toMap does not
make any guarantees about which mapping will be in the resulting map.
def traverse(f: a -> m[b] \ ef, c: Chain[a]): m[Chain[b]] \ ef with Applicative[m]§ SourceReturns the result of applying the applicative mapping function f to all the elements of the
chain c.
Returns a pair of chains, the first containing all first components in c
and the second containing all second components in c.
Deconstruct a Chain from left-to-right.
Returns ViewLeft(x, rs) if the chain is non-empty, where x is the leftmost
element of the chain c, and rs is the rest of the chain.
Returns ViewLeft.NoneLeft if the chain is empty.
Deconstruct a Chain from right-to-left.
Returns ViewRight(rs, x) if the chain is non-empty, where x is the rightmost
element of the chain c``, and rs` is the front of the chain.
Returns ViewRight.NoneRight if the chain is empty.
Returns a chain where the element at index i is (a, b) where
a is the element at index i in c1 and b is the element at index i in c2.
If either c1 or c2 becomes depleted, then no further elements are added to the resulting chain.
Returns a chain where the element at index i is f(a, b) where
a is the element at index i in c1 and b is the element at index i in c2.
If either c1 or c2 becomes depleted, then no further elements are added to the resulting chain.
def zipWithA(f: a -> (b -> m[c] \ ef), xs: Chain[a], ys: Chain[b]): m[Chain[c]] \ ef with Applicative[m]§ SourceGeneralize zipWith to an applicative functor f.