Iterator interface inspired on Python's iterator protocol.
A function that maybe compute the next element of an iterator
A state with a auxiliary numeric counter
Return Just the next value if iterator is not exausted or Nothing otherwise:
next numbers === Just 0
next empty === NothingAdvance iterator by one and return a tuple of ( iterator, value ):
(it, _) = step numbers
next it === Just 1Create a new iterator from a next function and an initial state.
The next function is called successfuly to advance the iterator and produce new values
Infinite iterator over the sequence of all numbers starting with a with
increments of 1.
Infinite iterator over the sequence of all numbers starting with a
increments of delta.
Create n numbers from a to b:
linspace 0 5 5 --> 0.0, 1.25, 2.5, 3.75, 5.0Make n steps of delta starting from a
stepsFrom 0 0.5 4 --> 0.0, 0.5, 1.0, 1.5This function is the basis for implementing countTo, range and linspace.
Infinite iterator that cycles among members of input list:
cycle [ 1, 2, 3 ] --> 1, 2, 3, 1, 2, 3, 1, 2, ...Successively apply function to initial argument:
power f x --> x, f x, f (f x), f (f (f x)), ...Successively apply function to initial argument. Repeat n times.
power 2 f x --> x, f x, f(f x)Construct iterator from index function that takes an integer and return the value of the corresponding position.
indexed f --> f(0), f(1), f(2), ...Return an iterator that only yields elements that agree with predicate.
Limit the iterator to n elements. If the original iterator has less than
n elements, fill the iterator with copies of a.
Creates a new iterator that maps f into each element of the iterator.
Creates a new iterator that maps f successively into elements of iterA and
iterB.
Zip two iterators (i.e., iterate over the tuples of (a, b) taken from iterA and iterB respectively.
zip itA itB --> ( a0, b0 ), ( a1, b1 ), ...Enumerate iterator counting from a:
enumerate n it --> (n, x0), (n + 1, x1), (n + 2, x2), ...Concatenate two iterators together:
concat itA itB --> a0, a1, ..., aN, b0, b1, ..., bNInterspace each element of iterator with the value of x:
interspace a it --> x0, a, x1, a, x2, a, ..., xNExtract list from iterator:
toList it === [ x0, x1, x2, ..., xN ]WARNING: This function should obviously never be used on infinite iterators.
Accumulative reduce: return an iterator over partial reductions of the input iterator.
Return true if all elements of iterator satisfy the given predicate
Return true if any element of iterator satisfy the given predicate
Return Just the largest element of iterator or Nothing if iterator is empty.
Return Just the lowest element of iterator or Nothing if iterator is empty.
Return the last element of or x if iterator is empty.
Base iterator type