diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-02-14 01:34:44 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-02-14 01:34:44 -0800 |
commit | 341ac57c0bcbdc31571ec0d63c63803d502c5a4a (patch) | |
tree | c53d8b9aa238a82cebafb5b4dd0813ec27b6edab /eval.c | |
parent | 6f8875ff5beadd34a3ce94c40bfc1dc36b26a114 (diff) | |
download | txr-341ac57c0bcbdc31571ec0d63c63803d502c5a4a.tar.gz txr-341ac57c0bcbdc31571ec0d63c63803d502c5a4a.tar.bz2 txr-341ac57c0bcbdc31571ec0d63c63803d502c5a4a.zip |
* eval.c (rangev_func): Improved termination test. The sequence
not only if it achieves the endpoint, but if it crosses it.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1666,19 +1666,22 @@ static val rangev_func(val env, val lcons) { cons_bind (from, to_step, env); cons_bind (to, step, to_step); + val next = if3(functionp(step), + funcall1(step, from), + plus(step, from)); rplaca(lcons, from); - if (equal(from, to)) { + if (eql(from, to) || + (lt(from, to) && gt(next, to)) || + (gt(from, to) && lt(next, to))) + { rplacd(lcons, nil); return nil; } - if (functionp(step)) - rplaca(env, funcall1(step, from)); - else - rplaca(env, plus(from, step)); rplacd(lcons, make_lazy_cons(lcons_fun(lcons))); + rplaca(env, next); return nil; } |