Module: RParsec::FunctorMixin

Module | RParsec::FunctorMixin
In: | rparsec/functors.rb

This module provides instance methods that manipulate closures in a functional style. It is typically included in Proc and Method.

### Methods

* ** << >> compose curry flip power repeat reverse_curry reverse_uncurry uncurry

### Public Instance methods

*(n)

Alias for repeat

**(n)

Alias for power

<<(other)

Alias for compose

>>(other)

a >> b is equivalent to b << a

compose(other)

Create a Proc, when called, the parameter is first passed into other, self is called in turn with the return value from other.

curry(ary=arity)

Create a Proc that‘s curriable. When curried, parameters are passed in from left to right. i.e. closure.curry.call(a).call(b) is quivalent to closure.call(a,b) . self is encapsulated under the hood to perform the actual job when currying is done. ary explicitly specifies the number of parameters to curry.

flip()

Create a Proc, which expects the two parameters in the reverse order of self.

power(n)

Create a Proc, when called, repeatedly call self for n times. At each iteration, return value from the previous iteration is used as parameter.

repeat(n)

Create a Proc, when called, repeatedly call self for n times. The same arguments are passed to each invocation.

reverse_curry(ary=arity)

Create a Proc that‘s curriable. When curried, parameters are passed in from right to left. i.e. closure.reverse_curry.call(a).call(b) is quivalent to closure.call(b,a) . self is encapsulated under the hood to perform the actual job when currying is done. ary explicitly specifies the number of parameters to curry.

reverse_uncurry()

Uncurry a reverse curried closure.

uncurry()

Uncurry a curried closure.

[Validate]