diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-03-07 00:11:37 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-03-07 00:11:37 -0800 |
commit | 07e40c025d65beeced5ac83485eb13dab9b7d2ae (patch) | |
tree | 8a6569af89018d5d9ff2622c8f7ad40fd236fd0e /lib.c | |
parent | a68a67376127cb9accf26c4ed43438f188eb24c8 (diff) | |
download | txr-07e40c025d65beeced5ac83485eb13dab9b7d2ae.tar.gz txr-07e40c025d65beeced5ac83485eb13dab9b7d2ae.tar.bz2 txr-07e40c025d65beeced5ac83485eb13dab9b7d2ae.zip |
New function: iterp.
* eval.c (eval_init): Register iterp intrinsic.
* lib.[ch] (iterp): New function.
* tests/012/iter.tl: New tests.
* txr.1: Document iterp. Update documentation for iter-more,
iter-item and iter-step to more precisely identify which
objects are valid arguments in terms of iterp and additional
conditions, and that other objects throw a type-error
exception. Fix wrong references to iter-more under
documentation for iter-item. Removed obsolete text specifying
that iter-step uses car on list-like sequences, a dubious
behavior removed in the previous commit.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -1440,6 +1440,28 @@ val iter_reset(val iter, val obj) } } +val iterp(val obj) +{ + switch (type(obj)) { + case NIL: + case CHR: + case NUM: + case BGNUM: + case FLNUM: + case CONS: + case LCONS: + return t; + case COBJ: + if (obj->co.cls == seq_iter_cls) + return t; + if (obj_struct_p(obj) && get_special_slot(obj, iter_step_m)) + return t; + /* fallthrough */ + default: + return nil; + } +} + val iter_catv(varg iters) { cnum index = 0; |