12:19Modius: jteo: What can lead to memory usage also are lazy sequences that make use of memoized links (some require these, e.g. certain self-referencing list solutions) - but the link back to the head (if you somehow keep one) causes all results to be preserved until the end of the computation, limiting how far you can traverse the sequence, or how many can be traversed in parallell with other actions that also use ram.

12:34 Modius: It's just a trade-off really, do you want to use CPU or do you want to use memory, and granted, if you're not careful you can leak more than you want to.

12:35Modius: vincenz: I'm not going to hawk my own library in someone else's pond; but I have one where I was able to do both -self-referencing AND memoization; but memoization only between the links, not to the head.

12:45jteo: cgrand: neat. now let me try to understand how it works. ;)

12:54 i'm having difficulty understanding why this one doesn't cause a stack overflow compared to the sieve implementation i tried.

13:05cgrand: jteo: in yours, when you have already got 3, 5 and 7 to get the next prime, you ask to your seq (which filter out multiples of 7) for the next item, which asks to its parent seq (filter out 5x) which asks to its parent seq (filter out 3x) which asks to the odd numbers seq. In mine I just loop over the list of known primes (in prime?).