Guest User

Untitled

a guest
Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. class Proc
  2. def cur(*args)
  3. self.call(self, *args)
  4. end
  5. end
  6. module Kernel
  7. def recursively(*args, &block)
  8. block.cur(*args)
  9. end
  10. end
  11.  
  12.  
  13.  
  14. x = recursively(10) do |re,n|
  15. n + (n > 0 ? re.cur(n-1) : 0)
  16. end
  17. puts x
Add Comment
Please, Sign In to add comment