Ion Fusion Documentation
Release 0.38a1-SNAPSHOT (2026-04-16T19:45:37.790Z)

Module /fusion/iterator

Stateful traversal of value sequences.

Fusion iterators are essentially identical to Java iterators, and their use is based on two procedures:

empty_iterator constant

An iterator with no elements. (iterator_has_next empty_iterator) always returns false, and (iterator_next empty_iterator) always throws an exception.

is_iterator procedure
(is_iterator value)

Checks if the value is an iterator. Returns true or false.

iterator_append procedure
(iterator_append iter1 iter2)

Returns an iterator that provides all the elements of iter1 and then all the elements of iter2.

iterator_choose procedure
(iterator_choose pred iter)

Returns an iterator whose elements are those provided by iter that satisfy predicate pred.

iterator_find procedure
(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 procedure
(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 procedure
(iterator_map proc iter)

Returns an iterator whose elements are the results of applying proc to the corresponding elements of iter.

iterator_map_splicing procedure
(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 procedure
(iterator_next iterator)

Returns the next element of the iterator. When the iterator has no more elements, an exception is thrown.

make_iterator procedure
(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 procedure
(value_iterator value)

Returns an iterator that produces value as its only element.