Friday, 29 April 2016

Haskell: abs: Get the absolute value of a number


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



Previous                                                 Next                                                 Home

No comments:

Post a Comment