[Haskell-cafe] map (-2) [1..5]
David House
dmhouse at gmail.com
Thu Aug 17 04:52:09 EDT 2006
On 17/08/06, Tamas K Papp <tpapp at princeton.edu> wrote:
> The code in the subject generates an error. I understand why this is
> (- is treated as part of the number), but I don't know how to solve
> it, ie how to tell Haskell that - is a function/binary operator?
There's a Prelude function for exactly this purpose, which leads your
code still quite readable:
Prelude> map (subtract 2) [1..5]
[-1,0,1,2,3]
--
-David House, dmhouse at gmail.com
More information about the Haskell-Cafe
mailing list