99 Elm Problems/Lists/Problem 1/Find the last element of a list

Find the last element of a list.

Example in Elm:

import Graphics.Element exposing (show)
import List
import Maybe

myLast : List a -> Maybe a
-- your implementation goes here

main =
  case myLast [1,2,3,4] of 
    Just a -> show a
    Nothing -> show "No element found"

Result:

4

Solutions