Module: Heist::Scheme::List

Defined in:
lib/heist/parser/nodes.rb

Overview

A List has an array of cells, and optionally a tail if it’s an improper list or a dotted pair.

Instance Method Summary collapse

Instance Method Details

#cellsObject



49
50
51
# File 'lib/heist/parser/nodes.rb', line 49

def cells
  @cells ||= elements[1].elements[0].elements
end

#evalObject

Evaluating a List produces a Heist Cons object.



43
44
45
46
47
# File 'lib/heist/parser/nodes.rb', line 43

def eval
  list = Runtime::Cons.construct(cells, true) { |c| c.eval }
  list.tail.cdr = tail.cell.eval if tail.respond_to?(:dot)
  list
end

#tailObject



53
54
55
# File 'lib/heist/parser/nodes.rb', line 53

def tail
  @tail ||= elements[1].elements[1]
end