(:) is a constructor. For example, you can define lists as: data List a = Nil | Cons a (List a) GHC does some magic to provide us with the same definition, but with Nil replaced by [] and Cons replaced by (:). As constructors can be pattern matched on, you can also match on a (:), which is a data constructor. You might consider (x:xs) as a tuple, only if you're willing to consider (Cons x xs) as a tuple. It is a tuple (ordered collection of two values), but not a tuple according to their definition in haskell. What kind of tuple are you talking about? Hope this helps. Regards, Sumit On 24 February 2016 at 16:01, Nan Xiao <xiaonan830818@gmail.com> 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