Sha256: d88f507e0e0b0b890a19799dff571d97cc1a7e496a3efbb318fbd038a3990e7e

Contents?: true

Size: 361 Bytes

Versions: 4

Compression:

Stored size: 361 Bytes

Contents

require 'ludy/symbol/to_proc'

class Array
  # example:
  #  [1,2,3].combine [2,4,6]
  #  => [3,6,9]
  #
  #  [1,2].combine [1,2], [1,2]
  #  => [3,6]
  #
  #  ['a','b'].combine ['b','a']
  #  => ['ab','ba']
  def combine *target; zip(*target).map{|i|i.inject(&:+)}; end
  # inplace version of combine
  def combine! *target; replace combine(*target); end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
godfat-ludy-0.1.13 lib/ludy/array/combine.rb
ludy-0.1.15 lib/ludy/array/combine.rb
ludy-0.1.11 lib/ludy/array/combine.rb
ludy-0.1.13 lib/ludy/array/combine.rb