Module: Algebrick::Types::List
- Includes:
- Enumerable
- Defined in:
- lib/algebrick/types.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(type, *items) ⇒ Object
64 65 66 |
# File 'lib/algebrick/types.rb', line 64 def self.build(type, *items) items.reverse_each.reduce(EmptyList) { |list, item| self[type][item, list] } end |
Instance Method Details
#each(&block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# 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? ⇒ Boolean
60 61 62 |
# File 'lib/algebrick/types.rb', line 60 def empty? !next? end |
#next? ⇒ Boolean
56 57 58 |
# File 'lib/algebrick/types.rb', line 56 def next? self.next != EmptyList end |