Funny. I don't get the same results for this last one:
Ilya Beylin writes:
> ? fac_log10 111111
> 512394.0
> (3000053 reductions, 4000087 cells, 16 garbage collections)
I get :
Main> fac_log10 111111
512387.574
(1777801 reductions, 3666665 cells, 5 garbage collections)
I'm using Hugs-1.4-971209 and this is what I ran:
-- Prelude doesn't export foldl'
foldl' :: Eval a => (a -> b -> a) -> a -> [b] -> a
foldl' f a [] = a
foldl' f a (x:xs) = strict (foldl' f) (f a x) xs
fac :: Integer->Integer
fac n = foldl' (*) 1 [1..n] -- Prelude.foldl' uses O(1) stack
mult x n = x + (log n)
fac_log n = foldl' mult 1 [1..n]
fac_log10 n = (fac_log n) / (log 10)