class MIKU::Cons

Attributes

car[R]
cdr[R]

Public Class Methods

list(*nodes) click to toggle source
# File core/miku/cons.rb, line 10
def self.list(*nodes)
  unless nodes.empty?
    carnode, *cdrnode = *nodes
    Cons.new(carnode, list(*cdrnode))
  end
end
new(car, cdr=nil) click to toggle source
# File core/miku/cons.rb, line 17
def initialize(car, cdr=nil)
  @car = car
  @cdr = cdr
end

Public Instance Methods

each(&proc) click to toggle source
# File core/miku/cons.rb, line 32
def each(&proc)
  proc.call @car
  @cdr.each(&proc) if(@cdr.is_a? Enumerable)
end
empty?() click to toggle source
# File core/miku/cons.rb, line 41
def empty?
  false
end
inspect() click to toggle source
# File core/miku/cons.rb, line 45
def inspect
  "(#{car.inspect}"+(if @cdr.is_a?(Cons) then " #{@cdr.inspect[1..-1]}"
                      elsif @cdr === nil then ')'
                      else " . #{@cdr.inspect})" end)
end
setcar(val) click to toggle source
# File core/miku/cons.rb, line 22
def setcar(val)
  @car = val
  self
end
setcdr(val) click to toggle source
# File core/miku/cons.rb, line 27
def setcdr(val)
  @cdr = val
  self
end
to_cons() click to toggle source
# File core/miku/cons.rb, line 37
def to_cons
  self
end