2009/3/12 7stud
<bbxx789_05ss@yahoo.com>
7stud <bbxx789_05ss <at>
yahoo.com> writes:
>
> Why does
>
> take (0 - 1) [1, 2, 3]
>
> produce a result but not
>
> take -1 [1, 2, 3]
>
> ? Thanks
>
Well, immediately after I hit the submit button, I thought I'd try this:
*Main> take (-1) [1, 2, 3]
[]
So why are the parentheses needed there?
I think because take -1 [1,2,3] is parsed as (take - 1 ) [1,2,3] or something like that.
If you look to the error message, and translate the haskellese in plain english, it says so.
"In the second argument of `(-)', namely `1 [1, 2, 3]' " :
so it looks like is looking for the two arguments of infix operator (-), the first being 'take'.
But I don't understand because it says that 1 [1,2,3] is a single argument...
"In the definition of `it': it = take - 1 [1, 2, 3]"
notice the blank between the minus sign and 1: even if you write -1, it understands - 1.
So, ghc is trying to be helpful here :-)
Ciao
-----
FB