Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created March 30, 2014 23:56
Show Gist options
  • Save marcoscastro/9882158 to your computer and use it in GitHub Desktop.
Save marcoscastro/9882158 to your computer and use it in GitHub Desktop.
larger value of list in haskell
-- 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