Module /fusion/series
Abstract, ordered collections that can be consumed by
for comprehensions.
A series is an abstract data type that produces any number of values in
order. Their primary use is as input to the various
for comprehension forms.
A number of built-in types are usable as series:
- Sequences (sexps and lists) are traversed in order, producing a single value at each step.
- Structs are traversed in an undefined order. Each step produces two values: the field name as a symbol, and the field value.
- Iterators produce one or more values as per
iterator_next.
This module provides constructors that can make new series from other sources of data.
Exported Bindings
A series that produces no elements.
(in_port)
Returns a series of elements produced by calling read.
In other words, the series produces the data on the
current Ion input port.
The current port can be locally parameterized to affect iteration over Ion data in files, lobs, or strings:
(with_ion_from_file "document.ion"
// The with_ion_from functions take a thunk:
(lambda ()
(series_to_list (in_port))))
=>
[1, k, {a:false}]
See /fusion/io for other ways to parameterize the current Ion input port.
(in_producer producer stop_pred)
Returns a series containing the results from calls
to the producer procedure.
At each step, the producer is invoked with no argument.
The stop_pred is then applied to the result(s), and if it
returns truthy then the series ends (without including those values).
Otherwise the producer's results are produced by the series.
(is_series value)
Determines whether a value is a series that can be
consumed by a for comprehension.