Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Proc
- def cur(*args)
- self.call(self, *args)
- end
- end
- module Kernel
- def recursively(*args, &block)
- block.cur(*args)
- end
- end
- x = recursively(10) do |re,n|
- n + (n > 0 ? re.cur(n-1) : 0)
- end
- puts x
Add Comment
Please, Sign In to add comment