# [plt-scheme] Unreasonably slow

I wrote this code for project euler problem 7:
(require r5rs)
(require srfi/41)
(define stream-primes
(let ((numbers (stream-cons 2 (stream-from 3 2)))
(filter-stream
(stream-lambda
(divisor strm)
(let ((not-div
(lambda (dividend)
(not (zero? (modulo dividend divisor))))))
(stream-filter not-div strm)))))
(stream-let
loop
((strm numbers)
(primes stream-null))
(define prime (stream-car strm))
(stream-append
(stream prime)
(loop (filter-stream prime (stream-cdr strm))
(stream-append primes (stream prime)))))))
and I ran (stream-ref stream-primes 10000)
It took unreasonably long to run. Much longer than it took my python code
(which uses python's generators, to which srfi/41's lazy comprehensions are
as close as I can find in scheme). I'm curious as to whether this is an
artifact of lazy comprehensions in scheme being slow or just my code being
wrong.
Thank you to anyone who takes the time to read this.
--
Alex R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081029/a19e28ec/attachment.html>