Created
June 22, 2016 10:42
-
-
Save tomcha/92a5c565eee85787ce7f5b5567620db7 to your computer and use it in GitHub Desktop.
recursion5.rb
This file contains 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
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