Create a gist now

Instantly share code, notes, and snippets.

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