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
No comments:
Post a Comment