Create a gist now

Instantly share code, notes, and snippets.

recursion6.rb
pro = Proc.new{|n| n % 2 == 0 ? true : false}
#list = [2, 4, 6, 8]
list = [3, 5, 7, 9]
def exists(list, pro)
if list.size == 0
false
elsif list.size == 1
pro.call(list.shift)
else
pro.call(list.shift) || exists(list, pro)
end
end
puts exists(list, pro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment