lib/nydp/pair.rb in nydp-0.1.15 vs lib/nydp/pair.rb in nydp-0.2.0
- old
+ new
@@ -25,11 +25,11 @@
else
from_list list
end
end
- def self.from_list list, last=Nydp.NIL, n=0
+ def self.from_list list, last=Nydp::NIL, n=0
if n >= list.size
last
else
new list[n], from_list(list, last, n+1)
end
@@ -50,49 +50,49 @@
def size
1 + (cdr.is_a?(Nydp::Pair) ? cdr.size : 0)
end
def proper?
- Nydp.NIL.is?(cdr) || (cdr.is_a?(Nydp::Pair) && cdr.proper?)
+ Nydp::NIL.is?(cdr) || (cdr.is_a?(Nydp::Pair) && cdr.proper?)
end
def each &block
yield car
- cdr.each(&block) unless Nydp.NIL.is?(cdr)
+ cdr.each(&block) unless Nydp::NIL.is?(cdr)
end
def inspect
"(#{inspect_rest})"
end
def to_s
if car.is_a?(Nydp::Symbol) && car.is?(:quote)
- if Nydp.NIL.is? cdr.cdr
+ if Nydp::NIL.is? cdr.cdr
"'#{cdr.car.to_s}"
else
"'#{cdr.to_s}"
end
elsif car.is_a?(Nydp::Symbol) && car.is?(:"brace-list")
- if Nydp.NIL.is? cdr
+ if Nydp::NIL.is? cdr
"{}"
else
"{ #{cdr.to_s_rest} }"
end
elsif car.is_a?(Nydp::Symbol) && car.is?(:quasiquote)
- if Nydp.NIL.is? cdr.cdr
+ if Nydp::NIL.is? cdr.cdr
"`#{cdr.car.to_s}"
else
"`#{cdr.to_s}"
end
elsif car.is_a?(Nydp::Symbol) && car.is?(:unquote)
- if Nydp.NIL.is? cdr.cdr
+ if Nydp::NIL.is? cdr.cdr
",#{cdr.car.to_s}"
else
",#{cdr.to_s}"
end
elsif car.is_a?(Nydp::Symbol) && car.is?(:"unquote-splicing")
- if Nydp.NIL.is? cdr.cdr
+ if Nydp::NIL.is? cdr.cdr
",@#{cdr.car.to_s}"
else
",@#{cdr.to_s}"
end
else
@@ -101,11 +101,11 @@
end
def to_s_rest
cdr_s = if cdr.is_a?(self.class)
cdr.to_s_rest
- elsif Nydp.NIL.is? cdr
+ elsif Nydp::NIL.is? cdr
nil
else
". #{cdr.to_s}"
end
@@ -113,20 +113,20 @@
end
def inspect_rest
cdr_s = if cdr.is_a?(self.class)
cdr.inspect_rest
- elsif cdr == Nydp.NIL
+ elsif cdr == Nydp::NIL
nil
else
". #{cdr.inspect}"
end
[car.inspect, cdr_s].compact.join " "
end
def append thing
- if Nydp.NIL.is? self.cdr
+ if Nydp::NIL.is? self.cdr
self.cdr = thing
elsif pair? self.cdr
self.cdr.append thing
else
raise "can't append #{thing} to list #{self} : cdr is #{self.cdr.inspect}"