Methods
Included Modules
Attributes
[RW] | first | |
[RW] | second |
Public Class methods
[ show source ]
# File lib/facets/more/lisp.rb, line 65 def DottedPair.[](*array) if array.empty? nil else DottedPair.new(array.shift, DottedPair[*array]) end end
[ show source ]
# File lib/facets/more/lisp.rb, line 59 def initialize(first = nil, second = nil) @first, @second = first, second end
Public Instance methods
[ show source ]
# File lib/facets/more/lisp.rb, line 104 def ==(other) if pair?(self) and pair?(other) car(self) == car(other) and cdr(self) == cdr(other) else if pair?(self) then false else self == other end end end
[ show source ]
# File lib/facets/more/lisp.rb, line 73 def each(&block) if @first if @first.is_a? DottedPair @first.each(&block) else block.call(@first) end end if @second if @second.is_a? DottedPair @second.each(&block) else block.call(@second) end end end
[ show source ]
# File lib/facets/more/lisp.rb, line 94 def inspect '(' + repr + ')' end
[ show source ]
# File lib/facets/more/lisp.rb, line 98 def to_a a = [] each { |e| a << e } a end
[ show source ]
# File lib/facets/more/lisp.rb, line 90 def to_s '(' + repr + ')' end
Protected Instance methods
[ show source ]
# File lib/facets/more/lisp.rb, line 114 def repr case @second when DottedPair then @first.to_s + ' ' + @second.repr when nil then @first.to_s else @first.to_s + ' . ' + @second.to_s end end