Created
January 23, 2017 10:44
-
-
Save maticzav/8a03e063bfcd1f548459aa61bb23e5af to your computer and use it in GitHub Desktop.
Elm - get one before last in list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getOneBeforeLast : List a -> Maybe a | |
getOneBeforeLast list = | |
case list of | |
[] -> Nothing | |
a :: _ :: [] -> Just a | |
_ :: a -> getOneBeforeLast a | |
-- getOneBeforeLast [1,2,3,4,5] == [4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment