Small functions to functionally augment ruby.
github.com
github.com
https://github.com/stefanpenner/rebinder/blob/master/lib/reb...
My syntax was far more sarcastic and less legitimate, however. eg:
add = Fixnum.☃.+
add3 = add.∂(3)
assert_equal 7, add3.☏(4)
The fun bit is that this implementation doesn't actually use lambdas, but rather (Unbound)Method instances. fib = +lambda {|n| return 1 if n <= 1; fib[n-2] + fib[n-1]} fib = +lambda {|n| return n if n <= 1; fib[n-1] + fib[n-1] }
My fibonacci is 0, 1, 1, 2, 3.. and yours is 1, 1, 2, 3... but doesn't make a difference as far as example goes.(sqr * inc)(5) ?
Blocks aren't objects - when they are converted to objects, they become procs. Procs are like blocks and lambdas are like methods, but you can't call either of them with () syntax.
And then there are multiple ways to call them:
f.call()
f[]
f.()
Take your pick.