Sha256: 67458af79fc5d184c676a46afc448e76834b9127ef7020c3de19cc63354c31c0

Contents?: true

Size: 481 Bytes

Versions: 38

Compression:

Stored size: 481 Bytes

Contents

module Abstractivator
  module Collections
    def multizip(enumerables, pad_value=nil)
      es = enumerables.map(&:each)
      result = []
      fail_count = 0
      while fail_count < es.size do
        fail_count = 0
        heads = es.map do |e|
          begin
            e.next
          rescue StopIteration
            fail_count += 1
            pad_value
          end
        end
        result << heads if fail_count < es.size
      end
      result
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
abstractivator-0.20.0 lib/abstractivator/collections.rb
abstractivator-0.19.0 lib/abstractivator/collections.rb
abstractivator-0.18.0 lib/abstractivator/collections.rb
abstractivator-0.17.0 lib/abstractivator/collections.rb
abstractivator-0.16.0 lib/abstractivator/collections.rb
abstractivator-0.15.0 lib/abstractivator/collections.rb
abstractivator-0.14.0 lib/abstractivator/collections.rb
abstractivator-0.13.0 lib/abstractivator/collections.rb
abstractivator-0.12.0 lib/abstractivator/collections.rb
abstractivator-0.11.0 lib/abstractivator/collections.rb
abstractivator-0.10.0 lib/abstractivator/collections.rb
abstractivator-0.8.0 lib/abstractivator/collections.rb
abstractivator-0.7.0 lib/abstractivator/collections.rb
abstractivator-0.6.0 lib/abstractivator/collections.rb
abstractivator-0.5.0 lib/abstractivator/collections.rb
abstractivator-0.4.1 lib/abstractivator/collections.rb
abstractivator-0.4.0 lib/abstractivator/collections.rb
abstractivator-0.3.1 lib/abstractivator/collections.rb
abstractivator-0.3.0 lib/abstractivator/collections.rb
abstractivator-0.2.0 lib/abstractivator/collections.rb