summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-07-10 01:11:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-07-10 01:11:19 -0700
commit42f2b87f012ca4980f326b0270b7a0c1fb34f5a0 (patch)
tree2246edf21d340566c6f43084117d47f865e2682e /lib.c
parent76789e6db8533da2ba9fd20cf66573d90ce22b4a (diff)
downloadtxr-42f2b87f012ca4980f326b0270b7a0c1fb34f5a0.tar.gz
txr-42f2b87f012ca4980f326b0270b7a0c1fb34f5a0.tar.bz2
txr-42f2b87f012ca4980f326b0270b7a0c1fb34f5a0.zip
split, split*, partition: tests, fixes.
* lib.c (partition_func): In empty index list case, run the sequence through sub(seq, zero, t) so that ranges are expanded: e.g. 1..3 becomes (1 2). The corresponding code in split_func and split_star_func also needs this fix, but the current test cases don't reproduce a problem. (partition_split_common): Likewise here. * tests/012/seq.tl: Tests for split, split* and partition. Some tests have questionable results. We accept these as they are for now; will address these.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index c0a4d850..8b6c261f 100644
--- a/lib.c
+++ b/lib.c
@@ -4228,7 +4228,7 @@ static val partition_func(val base, val lcons)
us_rplaca(lcons, first);
}
} else {
- us_rplaca(lcons, seq);
+ us_rplaca(lcons, sub(seq, zero, t));
us_rplacd(lcons, nil);
}
break;
@@ -4335,7 +4335,7 @@ static val partition_split_common(val seq, val indices,
indices = nullify(indices);
if (!indices)
- return cons(seq, nil);
+ return cons(sub(seq, zero, t), nil);
if (!seqp(indices))
indices = cons(indices, nil);