Haskell provides abs function, which
returns the absolute value of a number. Following is the signature of abs
function.
Prelude> :t abs abs :: Num a => a -> a
As you see the
signature, abs takes any value which is of number type and return the absolute
value.
Prelude> abs 10 10 Prelude> abs (-10) 10 Prelude> abs 10.01 10.01 Prelude> abs (-10.01) 10.01
No comments:
Post a Comment