In Files

Methods

Files

LazyList::ModuleFunctions

This module contains module functions, that are added to LazyList and it’s instances.

Public Instance Methods

delay(&block) click to toggle source

Delay the value of block to a Promise.

# File lib/lazylist.rb, line 58
    def delay(&block)
      MemoPromise.new(&block)
    end
force(obj) click to toggle source

Force the delayed obj to evaluate to its value.

# File lib/lazylist.rb, line 63
    def force(obj)
      case obj
      when Promise
        force obj.__value__
      else
        obj
      end
    end
mix(*lists) click to toggle source

Returns a LazyList, that consists of the mixed elements of the lists _lists without any special order.

# File lib/lazylist.rb, line 74
    def mix(*lists)
      return empty if lists.empty?
      first = lists.shift
      if lists.empty?
        first
      elsif first.empty?
        mix(*lists)
      else
        LazyList.new(first.head) do
          t = first.tail
          lists = lists.push t unless t.empty?
          mix(*lists)
        end
      end
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.