Re: Filtering lazy sequence on itself - Eratosthenes Sieve

2015-11-05 Thread Matthew Ulrich
range-peek > (filter (partial prime? primes)) > first)] > (cons p (lazy-seq (sieve (conj primes p))) > > (last (take 1 (sieve))) > > This version keeps the visited primes in a vector so it will grow in > memory but won’t overfl

Filtering lazy sequence on itself - Eratosthenes Sieve

2015-11-04 Thread Matthew Ulrich
All - I'm trying to generate a lazy sequence of primes using Erastosthenes Sieve (from Abelson & Sussman) and am encountering some issues with lazy sequence. Here's what I have: --- (defn divisible? [input numerator] (= 0 (mod input numerator))) (defn sieve [stream] (lazy-seq (con