diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-03-11 22:11:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-03-11 22:11:29 -0700 |
commit | 4098bdfbe0406bfacfc8a1b46bfad38964cfd2df (patch) | |
tree | 0e758878ad74a2925125fa48ed59a013203ed7ed /txr.1 | |
parent | 5e1107b94d8dca026a53cf8d8ab6f53d4a01cdac (diff) | |
download | txr-4098bdfbe0406bfacfc8a1b46bfad38964cfd2df.tar.gz txr-4098bdfbe0406bfacfc8a1b46bfad38964cfd2df.tar.bz2 txr-4098bdfbe0406bfacfc8a1b46bfad38964cfd2df.zip |
New sequence iterator object and functions.
* eval.c (eval_init): Register seq-begin, seq-next and
seq-reset.
* lib.c (seq_iter_s): New symbol variable.
(seq_iter_mark): New static function.
(seq_iter_ops): New static structure.
(seq_begin, seq_next, seq_reset): New functions.
(obj_init): Intern seq-iter symbol, used as class name for
iterators.
* lib.h (seq_iter_s, seq_begin, seq_next, seq_reset):
Declared.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -30332,6 +30332,66 @@ sequences using and tests for termination with .codn nil . +.SS* Open Sequence Traversal + +Functions in this category perform efficient traversal of sequences +of various kinds. + +.coNP Function @ seq-begin +.synb +.mets (seq-begin << object ) +.syne +.desc +The +.code seq-begin +function returns an iterator object specialized to the task of traversing +the sequence represented by the input +.metn object . + +If +.meta object +isn't a sequence, an exception is thrown. + +.coNP Function @ seq-next +.synb +.mets (seq-next < iter << end-value ) +.syne +.desc +The +.code seq-next +function retrieves the next available item from the sequence iterated by +.metn iter , +which must be an object returned by +.codn seq-begin . + +If the sequence has no more items to be traversed, then +.meta end-value +is returned instead. + +Note: to avoid ambiguities, the application should provide an +.meta end-value +which is guaranteed distinct from any item in the sequence, such as a +freshly allocated object. + +.coNP Function @ seq-reset +.synb +.mets (seq-reset < iter << object ) +.syne +.desc +The +.code seq-reset +re-initializes the existing iterator object +.meta iter +to begin a new traversal over the given +.metn object , +which must be a value of a kind that would be a suitable argument for +.codn seq-begin . + +The +.code seq-reset +function returns +.metn iter . + .SS* Procedural List Construction \*(TL provides an a structure type called |