[Haskell-cafe] Recursion in Haskell

P. R. Stanley prstanley at ntlworld.com
Sun Feb 18 22:22:10 EST 2007


Chaps,
is there another general pattern for mylen, head or tail?
mylen [] = 0
mylen (x:xs) = 1 + mylen (xs)

head [] = error "what head?"
head (x:xs) = x

tail [] = error "no tail"
tail (x:xs)= xs

This pattern matching reminds me of a module on formal spec I studied 
at college.
What are the pre-requisites for Lambda calculus?
Thanks
Paul



More information about the Haskell-Cafe mailing list