99 Elm Problems/Lists Problem 1/Find the last element of a list/Solutions
-- recursive search for the last element
myLast : List a -> Maybe a
myLast list =
case list of
[ ] -> Nothing
[a] -> Just a
b::c -> last c
—reverse and take the head
myLast : List a -> Maybe a
myLast list =
List.reverse list |> List.head