Sha256: 73e43f103a64c644214b9df113f4a2085b20fadf313204f3ce67670d806a05ef
Contents?: true
Size: 469 Bytes
Versions: 1
Compression:
Stored size: 469 Bytes
Contents
context :ImmutableStack do role :head do end role :tail do end def pop [@head, @tail] end def push(element) ImmutableStack.new element, self end def self.empty @empty ||= self.new(nil, nil) end def each yield head t = tail while t != ImmutableStack::empty do h, t = t.pop yield h end end def initialize(h, t) @head = h @tail = t self.freeze end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
maroon-0.8.0 | base/ImmutableStack.rb |