0

It seems that (-3) is treated as a negative number instead of a curried function in haskell.

if I write

map (+3) [1..3]

I get [4,5,6]

However, map (-3) [1..3] would cause an error.

So, How could I map (-) to a list elegantly instead of having to use map (\x->x-3) xs?

Alaya
  • 3,287
  • 4
  • 27
  • 39

2 Answers2

0

You can try:

map (flip (-) 3) [1..3]

-- or the other way around
map (3 -) [1..3]
Alexandr Kurilin
  • 7,685
  • 6
  • 48
  • 76
0

You could also do something like this:

map (-3 +) [1..3]