module Algebrick::Types::List
Public Class Methods
build(type, *items)
click to toggle source
# File lib/algebrick/types.rb, line 64 def self.build(type, *items) items.reverse_each.reduce(EmptyList) { |list, item| self[type][item, list] } end
Public Instance Methods
each(&block)
click to toggle source
# File lib/algebrick/types.rb, line 43 def each(&block) return to_enum unless block_given? it = self loop do break if EmptyList === it block.call it.value it = it.next end self end
empty?()
click to toggle source
# File lib/algebrick/types.rb, line 60 def empty? !next? end
next?()
click to toggle source
# File lib/algebrick/types.rb, line 56 def next? self.next != EmptyList end