Tuesday, 13 August 2013

Haskell: Binding In Functions

Haskell: Binding In Functions

I'm reading through Learn You A Haskell. I came upon this:
head' :: [a] -> a
head' [] = error "Can't call head on an empty list, dummy!"
head' (x:_) = x
What is going on in this function? I get that if the list is empty, it
reports that error. The 3rd line is puzzling, however; what does that x
and : do? What does : indicate in a haskell function?

No comments:

Post a Comment