At 13:13 Uhr -0400 17.10.2006, Lang Martin wrote:
That's just the one call to gensym, which vaguely seems like the most expensive part of doing it this way
You could move that outside the call path:
(define make-lazy (let* ((nothing (gensym)) (exit (lambda () nothing))) (lambda (generator) (let lp () (delay (let ((value (generator exit))) (if (eq? value nothing) '() (cons value (lp))))))))
, and should be as correct. Could write a generator to break it, but I don't suppose it'd happen accidently.
(The generator has to call the exit function in tail position now. Maybe better just feed it the nothing value -- or move the nothing value to the toplevel and export it to users, so the generator can become a thunk.)
Christian.
Afficher les réponses par date
At 20:37 Uhr +0200 17.10.2006, I wrote:
...
Or let the user provide the stop value:
(define (make-lazy generator #!optional nothing) (let lp () (delay (let ((value (generator exit))) (if (eq? value nothing) '() (cons value (lp)))))))
Christian.