Sha256: b4aca9e090e38658fb98b41521135a9f11b651e10f747609b50c7108444ced98
Contents?: true
Size: 470 Bytes
Versions: 2
Compression:
Stored size: 470 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
maroon-0.7.1 | base/ImmutableStack.rb |
maroon-0.7.0 | base/ImmutableStack.rb |