class RbScheme::LCell
Attributes
car[RW]
cdr[RW]
Public Class Methods
new(car = nil, cdr = nil)
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 22 def initialize(car = nil, cdr = nil) @car = car @cdr = cdr end
Public Instance Methods
==(another)
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 64 def ==(another) l1 = self l2 = another loop do if l1.is_a?(LCell) && l2.is_a?(LCell) return false unless l1.car == l2.car l1 = l1.cdr l2 = l2.cdr elsif !l1.is_a?(LCell) && !l2.is_a?(LCell) return l1 == l2 else return false end end end
cadddr()
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 51 def cadddr @cdr.cdr.cdr.car end
caddr()
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 47 def caddr @cdr.cdr.car end
cadr()
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 39 def cadr @cdr.car end
cddr()
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 43 def cddr @cdr.cdr end
each() { |car| ... }
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 27 def each list = self until list.null? yield(list.car) list = list.cdr end end
list?()
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 55 def list? cdr = @cdr loop do return false unless LCell === cdr return true if cdr.null? cdr = cdr.cdr end end
null?()
click to toggle source
# File lib/rb-scheme/lisp-objects.rb, line 35 def null? car == nil && cdr == nil end