411 REFERENCE · Wikibooks
99 Elm Problems/Problem 2/Solutions
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Solution 1: Recursive search for the next to last element
penultimate list =
case list of
[] -> Nothing
next :: [_] -> Just next
_ :: tail -> penultimate tail
Solution 2: Functional composition
import List exposing (reverse, drop, head)
penultimate =
(reverse >> drop 1 >> head)