class Cons

Attributes

car[R]
cdr[R]

Public Class Methods

new(car, cdr) click to toggle source
# File lib/schemerald/Cons.rb, line 4
def initialize(car, cdr)
  @car = car
  @cdr = cdr
end

Public Instance Methods

arrayify() click to toggle source
# File lib/schemerald/Cons.rb, line 9
def arrayify
  return self unless list?
  return [car] + cdr.arrayify
end
list?() click to toggle source
# File lib/schemerald/Cons.rb, line 14
def list?
  cdr.list?
end
scheme_eval(environment, forms) click to toggle source
# File lib/schemerald/Cons.rb, line 18
def scheme_eval(environment, forms)
  return forms.get_value(car).
    call(environment, forms, *cdr.arrayify) if forms.defined?(car)
  return car.scheme_eval(environment, forms).
    call(*cdr.arrayify.map{|x| x.scheme_eval(environment, forms)})
end
to_sxp() click to toggle source
# File lib/schemerald/Cons.rb, line 25
def to_sxp
  return "(#{car.to_sxp} . #{cdr.to_sxp})" unless list?
  return "(#{arrayify.map{|x| x.to_sxp}.join(' ')})"
end