Skip to content

Instantly share code, notes, and snippets.

@amiorin
Created July 22, 2013 15:28
Show Gist options
  • Save amiorin/6054762 to your computer and use it in GitHub Desktop.
Save amiorin/6054762 to your computer and use it in GitHub Desktop.
accumulator in ruby like javascript
#!/bin/env ruby
acc = lambda{|n|
lambda{|i|
n += i
}
}
foo = acc[3]
foo[1]
puts foo[1]
bar = acc[0]
bar[1]
bar[2]
bar[3]
puts bar[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment