Class: Construct
Instance Attribute Summary collapse
-
#car ⇒ Object
readonly
Returns the value of attribute car.
-
#cdr ⇒ Object
readonly
Returns the value of attribute cdr.
Instance Method Summary collapse
- #construct_list? ⇒ Boolean
-
#initialize(car, cdr) ⇒ Construct
constructor
A new instance of Construct.
- #lisp_eval(environment, forms) ⇒ Object
- #to_array ⇒ Object
Constructor Details
#initialize(car, cdr) ⇒ Construct
Returns a new instance of Construct.
4 5 6 |
# File 'lib/forsta/construct.rb', line 4 def initialize(car, cdr) @car, @cdr = car, cdr end |
Instance Attribute Details
#car ⇒ Object (readonly)
Returns the value of attribute car.
2 3 4 |
# File 'lib/forsta/construct.rb', line 2 def car @car end |
#cdr ⇒ Object (readonly)
Returns the value of attribute cdr.
2 3 4 |
# File 'lib/forsta/construct.rb', line 2 def cdr @cdr end |
Instance Method Details
#construct_list? ⇒ Boolean
8 9 10 |
# File 'lib/forsta/construct.rb', line 8 def construct_list? cdr.construct_list? end |
#lisp_eval(environment, forms) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/forsta/construct.rb', line 16 def lisp_eval(environment, forms) if forms.defined?(car) # TODO implement and test else car.lisp_eval(environment, forms). call(*cdr.to_array.map { |x| x.lisp_eval(environment, forms) }) end end |
#to_array ⇒ Object
12 13 14 |
# File 'lib/forsta/construct.rb', line 12 def to_array construct_list? ? [car] + cdr.to_array : self end |