
1 Jan
2011
1 Jan
'11
3:27 a.m.
On Sat, Jan 1, 2011 at 8:54 AM, Felipe Almeida Lessa wrote: On Fri, Dec 31, 2010 at 6:43 PM, aditya siram -- untested and won't work on an infinite list
last :: [a] -> a
last = head . reverse No definition for last works with infinite lists =). Unless you make the result nullable, of course.
maybeLast :: [a] -> Maybe a
maybeLast [] = Nothing
maybeLast [x] = Just x
maybeLast (_:xs) = maybeLast xs Cheers, --
Felipe. _______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe