Stephen Tetley <stephen.tet...@gmail.com> writes: >> oddSquareSum :: Integer >> oddSquareSum = sum . takeWhile (<10000) . filter odd . map (^2) $ [1..]
> Why filter out the evens after generating them? In other words: sum . takeWhile (<10000) . filter odd . map (^2) $ [1..] Since odd (x^2) => odd x: sum . takeWhile (<10000) . map (^2) $ [1,3..] Although it doesn't matter (more than a constant at any rate) for complexity, why generate values only to trim them later? Since x^2 < 10000 => x < 100: sum $ map (^2) [1,3..99] -k -- If I haven't seen further, it is by standing in the footprints of giants _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe