class Keisan::AST::List

Public Class Methods

new(children = []) click to toggle source
Calls superclass method
# File lib/keisan/ast/list.rb, line 4
def initialize(children = [])
  super(children)
end

Public Instance Methods

evaluate(context = nil) click to toggle source
# File lib/keisan/ast/list.rb, line 8
def evaluate(context = nil)
  return self if frozen?
  context ||= Context.new
  @children = children.map {|child| child.is_a?(Cell) ? child : child.evaluate(context)}
  self
end
simplify(context = nil) click to toggle source
# File lib/keisan/ast/list.rb, line 15
def simplify(context = nil)
  evaluate(context)
end
to_a() click to toggle source
# File lib/keisan/ast/list.rb, line 28
def to_a
  @children.map(&:value)
end
to_cell() click to toggle source
# File lib/keisan/ast/list.rb, line 32
def to_cell
  AST::Cell.new(
    self.class.new(
      @children.map(&:to_cell)
    )
  )
end
to_s() click to toggle source
# File lib/keisan/ast/list.rb, line 24
def to_s
  "[#{children.map(&:to_s).join(',')}]"
end
value(context = nil) click to toggle source
# File lib/keisan/ast/list.rb, line 19
def value(context = nil)
  context ||= Context.new
  children.map {|child| child.value(context)}
end

Private Instance Methods

cellify!() click to toggle source
# File lib/keisan/ast/list.rb, line 42
def cellify!
  @children = @children.map do |child|
    child.is_a?(Cell) ? child : Cell.new(child)
  end
end