class Hamster::Stream

def empty?

def empty?
  list = target
  while list.is_a?(Stream)
    list = list.target
  end
  list.empty?
end

def head

def head
  target.head
end

def initialize(&block)

def initialize(&block)
  @block = block
  @mutex = Mutex.new
end

def tail

def tail
  target.tail
end

def target

def target
  @mutex.synchronize do
    unless defined?(@target)
      @target = @block.call
      @block = nil
    end
  end
  @target
end