module Sequences

Public Instance Methods

drop(sequence, count) click to toggle source
# File lib/totally_lazy/sequence.rb, line 21
def drop(sequence, count)
  Sequence.drop(sequence, count)
end
empty() click to toggle source
# File lib/totally_lazy/sequence.rb, line 13
def empty
  Sequence.empty
end
enumerate(fn, start) click to toggle source
# File lib/totally_lazy/sequence.rb, line 45
def enumerate(fn, start)
  Sequence.new(Enumerator.new do |y|
    current = start
    loop do
      result = current
      current = fn.(current)
      y << result
    end
  end.lazy)
end
group(key, enumerator) click to toggle source
# File lib/totally_lazy/sequence.rb, line 33
def group(key, enumerator)
  Group.new(key, enumerator)
end
map_concurrently(sequence, fn=nil, &block) click to toggle source
# File lib/totally_lazy/sequence.rb, line 29
def map_concurrently(sequence, fn=nil, &block)
  Sequence.map_concurrently(sequence, block_given? ? ->(value) { block.call(value) } : fn)
end
repeat(item) click to toggle source
# File lib/totally_lazy/sequence.rb, line 37
def repeat(item)
  Sequence.new(repeat_enumerator(item))
end
repeat_fn(item) click to toggle source
# File lib/totally_lazy/sequence.rb, line 41
def repeat_fn(item)
  Sequence.new(repeat_fn_enumerator(item))
end
sequence(*items) click to toggle source
# File lib/totally_lazy/sequence.rb, line 17
def sequence(*items)
  Sequence.sequence(*items)
end
sort(sequence, comparator=ascending) click to toggle source
# File lib/totally_lazy/sequence.rb, line 25
def sort(sequence, comparator=ascending)
  Sequence.sort(sequence, comparator)
end

Private Instance Methods

pair_enumerator(left, right) click to toggle source
# File lib/totally_lazy/sequence.rb, line 58
def pair_enumerator(left, right)
  Enumerator.new do |y|
    left.rewind
    right.rewind
    loop do
      y << pair(left.next, right.next)
    end
  end.lazy
end