haskell - What do the parentheses signify in (x:xs) when pattern matching? -
When you split a list using x: xs syntax, then why is it wrapped in parentheses? What is the importance of brackets? Why not [x: xs] or just x: xs?
Opposition cell should not be bracket in every context, but in most contexts it is because < / P>
The function application becomes harder with any infix operator.
Burn it into your brain in a fire letter.
Example:
length [] = 0 length (x: xs) = 1 + length xs
if leaving the parentheses The compiler will be thought, then you have got a logic x
after an unlucky infix operator, and this bitter complaint will be done on the other hand it is ok
length L = the case l] - & gt; 0 x: xs - & gt; 1+ length xs
In this case neither x
and xs
possibly a function can be applied as part of the application Therefore there are no brackets required.
Note that the same unique rule function makes the application harder with any infix operator which is why we write 1 to write
without any brackets. Infix gives the rule and the infix rule goes away. length xs
Allows + length xs
Comments
Post a Comment