Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created June 22, 2016 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcha/2de8f0a55679fd16b2f181f52a51b894 to your computer and use it in GitHub Desktop.
Save tomcha/2de8f0a55679fd16b2f181f52a51b894 to your computer and use it in GitHub Desktop.
recursion4.rb
list = [5, 8, 2, 3]
def min(list)
if list.size == 1
list.shift
else
i = list.shift
list[0] = i if i < list[0]
min(list)
end
end
puts min(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment