
On Thu, Sep 17, 2009 at 01:50:27PM +0200, Daniel Fischer wrote:
Prelude> map ((-) 1) [1,2,3,4] [0,-1,-2,-3]
I know I can use an anonymous function, but I'm just trying to understand the result here... I'd appreciate any hints to help me graps this.
(-) a b = a - b, so (((-) 1) x) = 1 - x and you've mapped (\x -> 1-x) over the list.
Ah yes... Of course, I didn't realise that wrapping a binary operator in parens turns it into a normal function. And from http://www.haskell.org/onlinereport/exps.html#sect3.5, which someone pointed me to off-list, I gather that in (- 1) the minus sign is interpreted as the unary operator, not the binary one. Which means that (- 1) is not a function, which means map will barf. Ok, thanks, all makes sense now! Joost -- Joost Kremers Life has its moments