[Haskell-beginners] Why is this function that slow?

David Virebayre dav.vire+haskell at gmail.com
Thu Jul 29 03:51:02 EDT 2010


On Thu, Jul 29, 2010 at 2:02 AM, Bryce Verdier <bryceverdier at gmail.com> wrote:
> main :: IO ()
> main = print . maximum $ [ x * y | x <- nums, y <- nums, is_palimdrome (x *
> y)]
>   where nums main :: IO ()

This version of main is faster for me.

main :: IO ()
main = print . maximum $ [ x * y | x <- [100..1000], y <- [100..x],
is_palimdrome (x * y)]

David.


More information about the Beginners mailing list