Sha256: 6bcd696f4159ed293b24ca1f0aae5e7a0bf2c9be1d73cec34e2d5c7faec8af92

Contents?: true

Size: 419 Bytes

Versions: 1

Compression:

Stored size: 419 Bytes

Contents

# frozen_string_literal: true
class Enumerator
  def piecewise(*args)
    self.class.new(*args) do |yielder|
      each do |*values|
        yield yielder, *values
      end
    end
  end

  class Lazy
    def piecewise(*args, &block)
      self.class.new(self, *args, &block)
    end
  end if const_defined?(:Lazy)
end

module Enumerable
  def piecewise(*args, &block)
    each(*args).piecewise(&block).to_a
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
piecewise-0.3.0 lib/piecewise.rb