[Haskell-cafe] Re: Looking for the fastest Haskell primes
ekirpichov at gmail.com
Thu Apr 16 04:57:14 EDT 2009
The parameterless version is a top-level definition and won't get
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. <r.a.niemeijer at tue.nl>:
> 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 at haskell.org
Web IR developer, market.yandex.ru
More information about the Haskell-Cafe