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.1.1 lib/abstractivator/collections.rb
abstractivator-0.1.0 lib/abstractivator/collections.rb
abstractivator-0.0.31 lib/abstractivator/collections.rb
abstractivator-0.0.30 lib/abstractivator/collections.rb
abstractivator-0.0.29 lib/abstractivator/collections.rb
abstractivator-0.0.28 lib/abstractivator/collections.rb
abstractivator-0.0.27 lib/abstractivator/collections.rb
abstractivator-0.0.26 lib/abstractivator/collections.rb
abstractivator-0.0.25 lib/abstractivator/collections.rb
abstractivator-0.0.24 lib/abstractivator/collections.rb
abstractivator-0.0.23 lib/abstractivator/collections.rb
abstractivator-0.0.22 lib/abstractivator/collections.rb
abstractivator-0.0.21 lib/abstractivator/collections.rb
abstractivator-0.0.20 lib/abstractivator/collections.rb
abstractivator-0.0.19 lib/abstractivator/collections.rb
abstractivator-0.0.18 lib/abstractivator/collections.rb
abstractivator-0.0.16 lib/abstractivator/collections.rb
abstractivator-0.0.15 lib/abstractivator/collections.rb