diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-03-07 07:08:29 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-03-07 07:08:29 -0800 |
commit | 26f1f25a07a2b85b5481f0f5f1612c64bc76d910 (patch) | |
tree | 2563d5325552ba994520b3f0d064be3076316bb4 /lib.h | |
parent | 07e40c025d65beeced5ac83485eb13dab9b7d2ae (diff) | |
download | txr-26f1f25a07a2b85b5481f0f5f1612c64bc76d910.tar.gz txr-26f1f25a07a2b85b5481f0f5f1612c64bc76d910.tar.bz2 txr-26f1f25a07a2b85b5481f0f5f1612c64bc76d910.zip |
New feature: range iteration with skip.
The notation X..Y..Z now denotes an iterable range,
if X..Y is a valid iterable range on its own, and Z is a
positive integer. Z gives a step size: 1 takes every
element, 2 every other and so on.
* lib.c (seq_iter_get_skip, set_iter_peek_skip): New static
functions.
(si_skip_ops): New static structure.
(iter_dynamic): Function relocated earlier in file to avoid
forward declaration.
(seq_iter_init_with_info): When the iterated object is a
range, check for the to element itself being a range.
If so, it is potentially a skip iteration. Validate it
and implement via a skip iterator referencing a dynamic
range iterator.
* lib.h (struct seq_iter): New sub-union member, ul.skip.
We could use an existing member of type cnum;
this is for naming clarity.
* tests/012/iter.tl: New tests.
* txr.1: Documented.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -454,6 +454,7 @@ typedef struct seq_iter { cnum len; val vbound; cnum cbound; + cnum skip; val next; val dargs; } ul; |