Created
September 5, 2017 09:40
-
-
Save Nirma/6e53b0aff01c0bc18d3074bb86cdee0a to your computer and use it in GitHub Desktop.
This file contains 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
{- 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