> This computes 1000000!. This version takes 8m29.189s to execute. > Replace foldr1 with foldr and that goes down to 7m4.315s. Replace > product' with the Prelude product and it takes only 6m17.685s. Why is > that so? I'm using ghc 6.8.1 on Mac OS X.
I'm guessing that the speedup with the Prelude product is because it's a left fold. foldr goes to the end of the list and starts applying backwards, up the thunks. A left fold just keeps an accumulator as it walks down. The foldr1 to foldr speedup might be because foldr1 has three cases, to foldr's two: http://haskell.org/ghc/docs/latest/html/libraries/base/src/GHC-List.html#foldr1 AGL -- Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org 650-283-9641 _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
