I have a list areas :: [Double]. Now I want to filter this list for those which are actually integral values. I want to do something like this for my predicate:
isInteger :: Double -> Bool
isInteger x = abs (fromIntegral (floor x) - x) < delta
where delta = 0.00001
However, I would guess there is a better way to do this. Is there a Haskell idiom for checking if a real value is an integer?
This looks fine and idiomatic to me, though you probably want to use
roundrather thanfloor. You could also consider usingapproxRationaland checking that the denominator of the result is1: