Module /fusion/iterator
Stateful traversal of value sequences.
Fusion iterators are essentially identical to Java iterators, and their use is based on two procedures:
(iterator_has_next i)returns true or false to indicate whether iteratorihas another value to retrieve.(iterator_next i)returns the next value from the iterator, throwing a contract exception if there's no next value.
Exported Bindings
An iterator with no elements. (iterator_has_next empty_iterator) always
returns false, and (iterator_next empty_iterator) always throws an
exception.
(is_iterator value)
Checks if the value is an iterator. Returns true or false.
(iterator_append iter1 iter2)
Returns an iterator that provides all the elements of iter1 and then all the
elements of iter2.
(iterator_choose pred iter)
Returns an iterator whose elements are those provided by iter that satisfy
predicate pred.
(iterator_find pred iter)
Returns the first element of iter that satisfies predicate pred. If no
element satisfies the predicate, the result is void.
(iterator_has_next iterator)
Checks if the iterator will provide another value when iterator_next is
called. Returns true or false.
After this procedure returns false for some iterator instance, all
subsequent calls of iterator_has_next on the same instance are expected to
return false, and all subsequent calls of iterator_next are expected to
throw an exception.
(iterator_map proc iter)
Returns an iterator whose elements are the results of applying proc to the
corresponding elements of iter.
(iterator_map_splicing proc iter)
Returns an iterator that applies an iterator-making proc to each element of
iter, splicing the inner iterators into a single outer iterator.
(iterator_next iterator)
Returns the next element of the iterator. When the iterator has no more
elements, an exception is thrown.
(make_iterator has_next_proc next_proc)
Returns an iterator that delegates iterator_has_next and iterator_next to
the given procedures, which are usually closures with shared state.
(value_iterator value)
Returns an iterator that produces value as its only element.