diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-27 20:48:00 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-27 20:48:00 -0800 |
commit | 1291aa76a9c85ac50bc5ebe968fd332bdfe80af0 (patch) | |
tree | 1b60d04d27b3d82672172188c6778bc240e8af2d /lib.c | |
parent | b3a440ca242a07ed86f89d06208f15757d947e12 (diff) | |
download | txr-1291aa76a9c85ac50bc5ebe968fd332bdfe80af0.tar.gz txr-1291aa76a9c85ac50bc5ebe968fd332bdfe80af0.tar.bz2 txr-1291aa76a9c85ac50bc5ebe968fd332bdfe80af0.zip |
tuples: convert tuple generation to seq_build.
* lib.c (tuples_func): Replace list accumulation
with make_like with seq_build.
* tests/012/seq.tl: Fix one test case here which no
longer errors out. It produces a tuple which is not
a string, due to the inclusion of a non-character
object.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -3785,24 +3785,27 @@ val lazy_flatcar(val tree) static val tuples_func(val n, val lcons) { - list_collect_decl (out, ptail); + seq_build_t bu; us_cons_bind (iter_in, fill, lcons); val iter = iter_in; val count; + seq_build_init(lit("tuples"), &bu, iter); + for (count = n; count != zero && iter_more(iter); count = minus(count, one), iter = iter_step(iter)) - ptail = list_collect(ptail, iter_item(iter)); + seq_add(&bu, iter_item(iter)); if (!missingp(fill)) for (; gt(count, zero); count = minus(count, one)) - ptail = list_collect(ptail, fill); + seq_add(&bu, fill); if (iter_more(iter)) us_rplacd(lcons, make_lazy_cons_car_cdr(us_lcons_fun(lcons), iter, fill)); else us_rplacd(lcons, nil); - us_rplaca(lcons, make_like(out, iter_in)); + + us_rplaca(lcons, seq_finish(&bu)); return nil; } |