From 068b0cc761a6f17312057d65804d90f2579a7593 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 15 Mar 2019 07:06:38 -0700 Subject: flatcar*: eliminate state cons. * lib.c (lazy_flatcar_func, lazy_flatcar): Here, the state information consists of just one value. We just make that value itself the function's env, and mutate that env as needed. --- lib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib.c b/lib.c index 899ba9ba..e6ac7c48 100644 --- a/lib.c +++ b/lib.c @@ -2250,17 +2250,17 @@ static val lazy_flatcar_scan(val tree, val *cont) } } -static val lazy_flatcar_func(val env, val lcons) +static val lazy_flatcar_func(val tree, val lcons) { - val tree = us_car(env); val cont = nil; val atom = lazy_flatcar_scan(tree, &cont); + val fun = us_lcons_fun(lcons); rplaca(lcons, atom); - rplaca(env, cont); + us_func_set_env(fun, cont); if (cont) - us_rplacd(lcons, make_lazy_cons(us_lcons_fun(lcons))); + us_rplacd(lcons, make_lazy_cons(fun)); return nil; } @@ -2276,7 +2276,7 @@ val lazy_flatcar(val tree) if (!cont) return cons(nextatom, nil); - return make_lazy_cons(func_f1(cons(tree, nil), lazy_flatcar_func)); + return make_lazy_cons(func_f1(tree, lazy_flatcar_func)); } } -- cgit v1.2.3