call | -> | update |
Use a Proc as an observable.
CREDIT: Tim Pease |
Operator for Proc#compose and Integer#times_collect/of.
a = lambda { |x| x + 4 } b = lambda { |y| y / 2 } (a * b).call(4) #=> 6 (b * a).call(4) #=> 4
CREDIT: Dave
Returns a new proc that is the functional composition of two procs, in order.
a = lambda { |x| x + 4 } b = lambda { |y| y / 2 } a.compose(b).call(4) #=> 6 b.compose(a).call(4) #=> 4
CREDIT: Dave
Convert a Proc object into new partial Proc object.
a = proc { |a,b,c| a+b+c } b = a.partial(NA,2,NA) b[1,3] #=> 6
Note, the __ method, which used to be used in stay of NA, has been deprecated.
This method is similar to Proc#curry.
CREDT Trans
Convert Proc to method.
object = Object.new function = lambda { |x| x + 1 } function.to_method(object, 'foo') object.foo(1) #=> 2