How can I get sqrt
from Int
.
I try so:
sqrt . fromInteger x
But get error with types compatibility.
Perhaps you want the result to be an Int
as well?
isqrt :: Int -> Int
isqrt = floor . sqrt . fromIntegral
You may want to replace floor
with ceiling
or round
.
(BTW, this function has a more general type than the one I gave.)