diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-06-02 06:13:00 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-06-02 06:13:00 -0700 |
commit | dcd0c4e0485ad5f8cf571bffa99add57c8aed183 (patch) | |
tree | cd17a850e3434b749a7366adf9668cd5e1a11fe9 /lib.h | |
parent | 7d6e2b419916c915543e36f14891773294687b99 (diff) | |
download | txr-dcd0c4e0485ad5f8cf571bffa99add57c8aed183.tar.gz txr-dcd0c4e0485ad5f8cf571bffa99add57c8aed183.tar.bz2 txr-dcd0c4e0485ad5f8cf571bffa99add57c8aed183.zip |
New style iteration functions.
iter-begin provides a paradigm for iteration that is more
compatible with lists. If the sequence is a list, then the
list itself is returned as the iterator, and the other
functions are basicaly wrappers for car/cdr and null testing.
Yet the API is defined in such a way that other objects can be
iterated with good efficiency, at the cost of allocating a new
iterator object (which can be re-used).
* eval.c (eval_init): Register iter-begin, iter-more,
iter-item, iter-step and iter-reset.
* lib.c (seq_iter_init_with_info): New static function.
(seq_iter_init): Now a thin wrapper for
seq_iter_init_with_info.
(iter_begin, iter_more, iter_item, iter_step, iter_reset): New
functions.
* lib.h (iter_begin, iter_more, iter_item, iter_step,
iter_reset): New functions.
* txr.1: Documented.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -556,6 +556,11 @@ void seq_setpos(val self, seq_iter_t *it, val pos); val seq_begin(val obj); val seq_next(val iter, val end_val); val seq_reset(val iter, val obj); +val iter_begin(val obj); +val iter_more(val iter); +val iter_item(val iter); +val iter_step(val iter); +val iter_reset(val iter, val obj); val throw_mismatch(val self, val obj, type_t); INLINE val type_check(val self, val obj, type_t typecode) { |