Personal tools

99 questions/Solutions/1

From HaskellWiki

< 99 questions | Solutions
Revision as of 15:09, 13 July 2010 by Wapcaplet (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

(*) Find the last element of a list.

myLast :: [a] -> a
myLast [x] = x
myLast (_:xs) = myLast xs
 
myLast' = foldr1 (const id)
 
myLast'' = head . reverse
The
Prelude
also provides the function
last
.