Skip to content

Instantly share code, notes, and snippets.

@trek
Created November 5, 2008 18:01
Show Gist options
  • Select an option

  • Save trek/22387 to your computer and use it in GitHub Desktop.

Select an option

Save trek/22387 to your computer and use it in GitHub Desktop.
def search(v,a)
return if a.empty?
if a.pop == v
return search(v,a) + 1 rescue 1
else
return search(v,a) + 0 rescue 0
end
end
search(1,[1,2,3,4,3,4,4,4,1,1,4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment