diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-28 19:17:57 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-28 19:17:57 -0800 |
commit | 4f106ec38761c223304b74acfae490127beca464 (patch) | |
tree | 43967fdb5ef81624b0d4d65c0860029a9e0cc078 | |
parent | 001147e1d3a37718c4b75c2d56ea475455707464 (diff) | |
download | txr-4f106ec38761c223304b74acfae490127beca464.tar.gz txr-4f106ec38761c223304b74acfae490127beca464.tar.bz2 txr-4f106ec38761c223304b74acfae490127beca464.zip |
partition-by: replace tuple accumulation with seq_build.
* lib.c (partition_by_func): Use seq_build instead of
list_collect_decl and make_like.
-rw-r--r-- | lib.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -3896,12 +3896,13 @@ val tuples_star(val n, val seq, val fill) static val partition_by_func(val func, val lcons) { - list_collect_decl (out, ptail); - us_cons_bind (flast, seq_in, lcons); - val seq = seq_in; + seq_build_t bu; + us_cons_bind (flast, seq, lcons); val fnext = nil; - ptail = list_collect(ptail, pop(&seq)); + seq_build_init(lit("partition-by"), &bu, seq); + + seq_add(&bu, pop(&seq)); while (seq) { val next = car(seq); @@ -3910,7 +3911,7 @@ static val partition_by_func(val func, val lcons) if (!equal(flast, fnext)) break; - ptail = list_collect(ptail, next); + seq_add(&bu, next); seq = cdr(seq); flast = fnext; @@ -3919,7 +3920,7 @@ static val partition_by_func(val func, val lcons) us_rplacd(lcons, if2(seq, make_lazy_cons_car_cdr(us_lcons_fun(lcons), fnext, seq))); - us_rplaca(lcons, make_like(out, seq_in)); + us_rplaca(lcons, seq_finish(&bu)); return nil; } |