[Haskell-beginners] safetail problem
David Place
d at vidplace.com
Tue Jul 12 23:48:37 CEST 2011
On Jul 12, 2011, at 4:45 PM, Roelof Wobben wrote:
> But I can't find anything in the first 4 chapters from that book why I must use (0,x) en what that means.
I think lists can be confusing for someone who is trying to learn Haskell and has only used imperative languages before. Typically, those languages use arrays to manipulate lists of things.
The meaning of lists in Haskell is hidden by the confusing but convenient syntactic sugar used to write them. Really, lists are a recursive data type with two cases.
The basis case: the empty list (written as "[]", close square bracket then open square bracket)
The inductive case: a : List (here ":" is the constructor)
So, if we see a list written as [1,2,3,4] it really means (1 : (2 : (3 : (4 : []))))
All the programs that work on lists use the underlying representation, so you really need to understand it.
This confusion goes all the way back to 1960. Blame it on John McCarthy, inventor of Lisp!
I hope that is a little helpful.
Cheers,
David
____________________
David Place
Owner, Panpipes Ho! LLC
http://panpipesho.com
d at vidplace.com
More information about the Beginners
mailing list