-- Instead of this-- sumMultiples3or5 s = sum [x | x <- [3..s-1], x `mod` 3 == 0 || x `mod` 5 == 0]
-- Isn't this fastersumMultiples3or5 s = sum ([x | x <- [3,6..s-1]] `merge` [x | x <- [5,10..s-1]])
merge xs [] = xs
merge [] ys = ys
merge txs@(x:xs) tys@(y:ys)
| x < y = x : xs `merge` tys
| x > y = y : txs `merge` ys
| otherwise = x : xs `merge` ys
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
