Friday 29 April 2016

Haskell: negate: Change the sign of a number


Haskell provides negate function, which change the sign of a number. Following is the signature of negate function.
Prelude> :t negate
negate :: Num a => a -> a


As you see the signature, negate function takes any value, which is of type number and change the sign.
Prelude> negate 10
-10
Prelude> negate (-10)
10
Prelude> negate 10.01
-10.01
Prelude> negate (-10.01)
10.01



Previous                                                 Next                                                 Home

No comments:

Post a Comment