
Hi all,
Firstly, thanks very much for all responses!
Rein referred "A tuple can have any number of elements", while Graham
referred "There's no "one-ple", or 1-tuple, in Haskell.". So which one
is right? The tuple at least contains 2 elements?
Thanks very much in advance!
Best Regards
Nan Xiao
On Thu, Feb 25, 2016 at 2:37 AM, Graham Gill
Hi Nan, are you just confused about the use of the parentheses "(" and ")"?
(x1,x2), (x1,x2,x3), ... are tuples in Haskell, but (x:xs) is not. (There's no "one-ple", or 1-tuple, in Haskell.) In
occurs value [] = 0 occurs value (x:xs) = (if value == x then 1 else 0) + occurs value xs
the "(" and ")" around "x:xs" are just there for grouping, for operator precedence reasons. Function application binds more tightly than ":". If you leave the parentheses off, such as in
occurs value x:xs = ...
you'll get a parse error.
Graham
On 2/24/2016 5:31 AM, Nan Xiao wrote:
Hi all,
Greetings from me!
I am confused about the function parameters and tuple. E.g.:
occurs value [] = 0 occurs value (x:xs) = (if value == x then 1 else 0) + occurs value xs
should we consider (x:xs) as a tuple?
Thanks in advance!
Best Regards Nan Xiao _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners