
12 Jan
2008
12 Jan
'08
5:12 p.m.
"Rafael Almeida"
perfectSquares :: [Integer] perfectSquares = zipWith (*) [1..] [1..]
isPerfectSquare :: Integer -> Bool isPerfectSquare x = (head $ dropWhile (
what about module Main where isPerfectSquare :: Integer -> Bool isPerfectSquare n = sqrrt == fromIntegral (truncate sqrrt) where sqrrt = sqrt $ fromIntegral n ? It's a hell alot faster, but I have no idea if some numerical property of square roots could make it give different results than your version, in rare cases. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited.