Created
December 14, 2016 17:53
-
-
Save lipemorais/9501e180086113115e0d15a434ffcef6 to your computer and use it in GitHub Desktop.
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
myLast :: Eq a => [a] -> a | |
myLast (x:xs) | |
| xs == [] = x | |
| otherwise = myLast xs | |
myLast' :: Eq a => [a] -> a | |
myLast' (x:y:xs) | |
| xs == [] = x | |
| otherwise = myLast' (y:xs) | |
elementAt :: (Eq b, Num b) => [a] -> b -> a | |
elementAt list 1 = head list | |
elementAt (primeiro:list) index = elementAt list ((-) index 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment