Created
March 30, 2014 23:56
-
-
Save marcoscastro/9882158 to your computer and use it in GitHub Desktop.
larger value of list in haskell
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
-- maior valor de uma lista | |
maior [a] = a | |
maior (a:x) = if (a > (maior x)) then a else (maior x) | |
-- segunda forma de fazer | |
maior2 [a] = a | |
maior2 (a:b:x) | a > b = maior2(a:x) | |
| otherwise = maior2(b:x) | |
-- terceira forma de fazer (mais eficiente) | |
maior3 [a] = a | |
maior3 (a:x) | a > (maior3 x) = a | |
| otherwise = (maior3 x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment