lib/rupture/list.rb in rupture-0.1.0 vs lib/rupture/list.rb in rupture-0.2.0
- old
+ new
@@ -4,28 +4,26 @@
alias create new
end
private_class_method :create
attr_reader :seq, :size
- def self.empty
- @empty ||= create(nil, 0)
- end
-
def initialize(seq, size)
@seq = seq.seq
@size = size
end
def self.new(*args)
- list = self.empty
+ list = Empty
args.reverse_each do |x|
list = list.conj(x)
end
list
end
def conj(x)
self.class.send(:create, Cons.new(x, @seq), @size.inc)
end
+
+ Empty = create(nil, 0)
end
end