class Klam::Cons

Attributes

hd[R]
tl[R]

Public Class Methods

new(hd, tl) click to toggle source
# File lib/klam/cons.rb, line 6
def initialize(hd, tl)
  @hd = hd
  @tl = tl
end

Public Instance Methods

==(other) click to toggle source
# File lib/klam/cons.rb, line 11
def ==(other)
  other.instance_of?(Cons) && other.hd == @hd && other.tl == @tl
end
each() { |hd| ... } click to toggle source
# File lib/klam/cons.rb, line 19
def each
  x = self
  until x == Klam::Primitives::Lists::EMPTY_LIST
    yield x.hd
    x = x.tl
  end
end
hash() click to toggle source
# File lib/klam/cons.rb, line 15
def hash
  [@hd, @tl].hash
end