[Haskell-beginners] my own last function
doaltan at yahoo.co.uk
Sat Feb 18 19:18:24 CET 2012
Hello everyone, I have just started studying and started trying to solve 99 questions in haskell.org. However I got stuck even in the first question. The first question wants me to write my own last function and I wrote this :
q1mylast :: [x] -> x
q1mylast [a] = if length [a] <=1 then a
else q1mylast (tail [a])
This program doesn't work and it gives this error :
Program error: pattern match failure: q1mylast "doaltan"
I'll be very glad if you could tell me what's wrong with the code and how can I fix it..
Thanks in advance :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners