Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

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

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

-- 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