Class: Wallace::GE::GrammarDerivation
- Inherits:
-
String
- Object
- String
- Wallace::GE::GrammarDerivation
- Defined in:
- lib/modules/ge/grammar_derivation.rb
Overview
The GrammarDerivation class is used to hold a derivation of a grammar produced by some provided sequence of integers. This class implements methods for transforming the derivation into other forms.
Class Method Summary collapse
-
.to_lambda(args, derivation) ⇒ Object
Produces a lambda function from a given grammar derivation and a set of arguments.
Instance Method Summary collapse
-
#to_lambda(args) ⇒ Object
Converts this derivation into a usable lambda function.
Class Method Details
.to_lambda(args, derivation) ⇒ Object
Produces a lambda function from a given grammar derivation and a set of arguments.
Parameters:
-
args, an ordered array of the arguments to the lambda function.
-
derivation, the grammar derivation to use as the body of the function.
Returns: The corresponding lambda function.
15 16 17 |
# File 'lib/modules/ge/grammar_derivation.rb', line 15 def self.to_lambda(args, derivation) eval("lambda { |#{args.join(',')}| #{derivation} }") end |
Instance Method Details
#to_lambda(args) ⇒ Object
Converts this derivation into a usable lambda function.
Parameters:
-
args, an ordered array of the arguments to the lambda function.
Returns: The corresponding lambda function.
26 27 28 |
# File 'lib/modules/ge/grammar_derivation.rb', line 26 def to_lambda(args) Wallace::GE::GrammarDerivation.to_lambda(args, self) end |