(Copied solution from 99 questions/1 to 10)
Revision as of 10:27, 29 March 2011
(*) Find the last element of a list.
myLast :: [a] -> a myLast [x] = x myLast (_:xs) = myLast xs myLast' = foldr1 (const id) myLast'' = head . reverse myLast''' xs = xs !! (length xs - 1)
also provides the function