| Module | RParsec::Functors |
| In: |
rparsec/functors.rb
|
This module provides frequently used functors.
| Id | = | proc {|x|x} |
| Idn | = | proc {|*x|x} |
| Neg | = | proc {|x|-x} |
| Inc | = | proc {|x|x+1} |
| Dec | = | proc {|x|x-1} |
| Plus | = | proc {|x,y|x+y} |
| Minus | = | proc {|x,y|x-y} |
| Mul | = | proc {|x,y|x*y} |
| Div | = | proc {|x,y|x/y} |
| Mod | = | proc {|x,y|x%y} |
| Power | = | proc {|x,y|x**y} |
| Not | = | proc {|x,y|!x} |
| And | = | proc {|x,y|x&&y} |
| Or | = | proc {|x,y|x||y} |
| Xor | = | proc {|x,y|x^y} |
| BitAnd | = | proc {|x,y|x&y} |
| Union | = | proc {|x,y|x|y} |
| Match | = | proc {|x,y|x=~y} |
| Eq | = | proc {|x,y|x==y} |
| Ne | = | proc {|x,y|x!=y} |
| Lt | = | proc {|x,y|x<y} |
| Gt | = | proc {|x,y|x>y} |
| Le | = | proc {|x,y|x<=y} |
| Ge | = | proc {|x,y|x>=y} |
| Compare | = | proc {|x,y|x<=>y} |
| Call | = | proc {|x,y|x.call(y)} |
| Feed | = | proc {|x,y|y.call(x)} |
| Fst | = | proc {|x,_|x} |
| Snd | = | proc {|_, x|x} |
| At | = | proc {|x,y|x[y]} |
| To_a | = | proc {|x|x.to_a} |
| To_s | = | proc {|x|x.to_s} |
| To_i | = | proc {|x|x.to_i} |
| To_sym | = | proc {|x|x.to_sym} |
| To_f | = | proc {|x|x.to_f} |
Create a Proc, when called, the parameter is first passed into _f2_, _f1_ is called in turn with the return value from other.
Create a Proc that‘s curriable. When curried, parameters are passed in from left to right. i.e. curry(closure).call(a).call(b) is quivalent to closure.call(a,b) . block is encapsulated under the hood to perform the actual job when currying is done. arity explicitly specifies the number of parameters to curry.
Create a Proc, when called, repeatedly call block for n times. At each iteration, return value from the previous iteration is used as parameter.
Create a Proc, when called, repeatedly call block for n times. The same arguments are passed to each invocation.
Create a Proc that‘s curriable. When curried, parameters are passed in from right to left. i.e. reverse_curry(closure).call(a).call(b) is quivalent to closure.call(b,a) . block is encapsulated under the hood to perform the actual job when currying is done. arity explicitly specifies the number of parameters to curry.