Currying subtraction
Solution 1:
You can use the subtract
function instead of -
if you want to right-section subtraction:
map (subtract 1) [1..5]
Solution 2:
Since -
is both the infix subtract and the prefix negate, you can't use the (*x)
(where * is an infix operator and x a value) syntax for -
. Luckily Prelude comes with negate
and subtract
, which is \x -> -x
and \x y -> y-x
respectively, so that you may use those where you need to differentiate between the two.