[Haskell-cafe] Re: newbie optimization question

Peter Hercek peter at syncad.com
Mon Oct 29 03:48:45 EDT 2007


Don Stewart wrote:
>> perfect :: [Int]
>> perfect = [i | i<-[1..10000], i == sum (divisors i)]
>>
> 
> This should be a little faster , as sum will fuse,
> 
>     perfect :: [Int]
>     perfect = [i | i<-[1..10000], i == sum' (divisors i)]
>         where sum' = foldr (+) 0

sum' did not help. Times are about the same with Int type.

Peter.



More information about the Haskell-Cafe mailing list