99 Elm Problems/Problem 1/Solutions
Solution 1: Recursive search for the last element
myLast list =
case list of
[] -> Nothing
[a] -> Just a
b::c -> myLast c
Solution 2: Reverse and take the head
myLast = List.reverse >> List.head
Solution 3: Using List.foldl
myLast = List.foldl (\x _ -> Just x) Nothing