Created
September 25, 2015 14:29
-
-
Save namxam/bb2c1410c6a8965f530e 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
defmodule Exercise1 do | |
def maximum([head | tail]) do | |
maximum(tail, head) | |
end | |
defp maximum([], largest_score) do | |
largest_score | |
end | |
defp maximum([head | tail], largest_score) when largest_score > head do | |
maximum(tail, largest_score) | |
end | |
defp maximum([head | tail], _largest_score) do | |
maximum(tail, head) | |
end | |
end | |
[6, 4, 5, 3, 2, 7, 8, 10, 9, 1] | |
|> Exercise1.maximum | |
|> IO.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment