summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-07-07 21:15:41 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-07-07 21:15:41 -0700
commit17369f7c13b842646b0d6384614bd16dddb7d753 (patch)
tree233618d28ae53ee7af976eef7aa6dfd2a5a782c1
parent38aa3c8192f69252e09d844616cba32714eb8d59 (diff)
downloadtxr-17369f7c13b842646b0d6384614bd16dddb7d753.tar.gz
txr-17369f7c13b842646b0d6384614bd16dddb7d753.tar.bz2
txr-17369f7c13b842646b0d6384614bd16dddb7d753.zip
sub: don't produce an iterator.
Having the sub function yield an iterator in some cases is a defective requirement, causing problems like this: 1> (partition 1..10 '(2 3)) ((1 2) (3) #<seq-iter: a24c380>) With fix: 1> (partition 1..10 '(2 3)) ((1 2) (3) (4 5 6 7 8 9)) * lib.c (sub_iter): When the interval is open and we are operating on a sequence via iter-begin, do not return an iterator. Convert it to a lazy list. Not subjecting this to -C compat flag; I can't imagine anyone writing code to depend on this, rather than stepping around it as a bugx. * txr.1: Documentation updated.
-rw-r--r--lib.c2
-rw-r--r--txr.16
2 files changed, 4 insertions, 4 deletions
diff --git a/lib.c b/lib.c
index 8418844a..52f984e3 100644
--- a/lib.c
+++ b/lib.c
@@ -3014,7 +3014,7 @@ static val sub_iter(val obj, val from, val to)
if (!to) {
do {
if (ge(idx, from))
- return iter_dynamic(&iter);
+ return list_seq(iter_dynamic(&iter));
idx = succ(idx);
} while (seq_get(&iter, &elem));
} else {
diff --git a/txr.1 b/txr.1
index bda03dcc..c18ee4ce 100644
--- a/txr.1
+++ b/txr.1
@@ -34701,14 +34701,14 @@ argument may also be any other object type that is suitable as input to the
.code iter-begin
function. In this situation, assigning to
.code sub
-syntax produces an error. The behavior is complex. In cases where the
+syntax produces an error. Furthermore, in cases where the
.meta from
and
.meta to
arguments imply that a suffix of
.meta sequence
-is required, an iterator may be returned which traverses the suffix
-of the sequence. In other cases, a list of the elements selected by
+is required, an lazy list of the suffix of the iterated sequence
+will be returned. In other cases, a regular list of the elements selected by
.code sub
is returned.