
The parameterless version is a top-level definition and won't get
garbage-collected, IIRC.
So, if you evaluate primes!!10000000, you'll end up with a
10000000-element list hanging in memory forever.
If you evaluate (primes' ()) !! 10000000, you won't.
2009/4/16 Niemeijer, R.A.
Heinrich Apfelmus wrote:
+1 except that exporting the potentially infinite list of primes is problematic in that it may become a memory leak.
I'd suggest to export two versions
primes :: [Integer] primes' :: () -> [Integer]
for casual (i.e. throwaway program to solve a Project Euler problem) and for memory aware use respectively.
I'm afraid I don't quite follow. Would you mind explaining what the first parameter is for and how it would solve the memory leak? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Web IR developer, market.yandex.ru