
On Sun, 2007-10-28 at 23:34 +0100, Peter Hercek wrote:
Don Stewart wrote:
C++ version times: 1.109; 1.125; 1.125 Int32 cpu times: 1.359; 1.359; 1.375 Int64 cpu times: 11.688; 11.719; 11.766 Integer cpu times: 9.719; 9.703; 9.703
Great result from ghc.
What Haskell program were you using for this test? The original naive/high level implementation?
-- Don
Here it is (I played only with the types for divisors and perfect; bottom is there from my previous tests, but it should not matter): <---cut--->
module Main (bottom, divisors, perfect, main) where import Data.Int
bottom = error "_|_"
divisors :: Int -> [Int] divisors i = [j | j<-[1..i-1], i `mod` j == 0]
perfect :: [Int] perfect = [i | i<-[1..10000], i == sum (divisors i)]
main = print perfect
Try with rem instead of mod. (What the heck is with bottom?)