Skip to content

Instantly share code, notes, and snippets.

@Nirma
Created September 5, 2017 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nirma/6e53b0aff01c0bc18d3074bb86cdee0a to your computer and use it in GitHub Desktop.
Save Nirma/6e53b0aff01c0bc18d3074bb86cdee0a to your computer and use it in GitHub Desktop.
{- My personal solutions for problems 1 through 10 of
- https://wiki.haskell.org/99_questions/1_to_10-}
-- Problem 1: Find the last element of a list
problemOne :: [a] -> a
problemOne x = last x
-- Problem 2: Find the second to last element
problemTwo :: [a] -> a
problemTwo x = (!!1) $ reverse x
main = print $ problemTwo [1,2,3,4,5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment