Sha256: 0463db62a9475d9f8c28e46c94a6d71d8cdce7a55cb1de7f3e23555c4e9a8887

Contents?: true

Size: 295 Bytes

Versions: 22

Compression:

Stored size: 295 Bytes

Contents


# inverse from Tilo Sloboda (now in facets)

class Hash
  def inverse
    i = Hash.new
    self.each_pair do |k,v|
      if (Array === v) ; v.each{ |x| i[x] = ( i.has_key?(x) ? [k,i[x]].flatten : k ) }
      else ; i[v] = ( i.has_key?(v) ? [k,i[v]].flatten : k ) end
    end ; i  
  end
end


Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
mspire-0.10.8.0 lib/hash/inverse.rb
mspire-0.10.7.3 lib/hash/inverse.rb
mspire-0.10.7.2 lib/hash/inverse.rb
mspire-0.10.7.1 lib/hash/inverse.rb
mspire-0.10.7 lib/hash/inverse.rb
mspire-0.10.6 lib/hash/inverse.rb
mspire-0.10.5 lib/hash/inverse.rb
mspire-0.10.4 lib/hash/inverse.rb
mspire-0.10.3 lib/hash/inverse.rb
mspire-0.10.2 lib/hash/inverse.rb
mspire-0.10.1 lib/hash/inverse.rb
mspire-0.10.0 lib/hash/inverse.rb
mspire-0.9.2 lib/hash/inverse.rb
mspire-0.9.1 lib/hash/inverse.rb
mspire-0.9.0 lib/hash/inverse.rb
mspire-0.8.7 lib/hash/inverse.rb
mspire-0.8.6.2 lib/hash/inverse.rb
mspire-0.8.6.1 lib/hash/inverse.rb
mspire-0.8.6 lib/hash/inverse.rb
ms-quant-0.1.1 lib/hash/inverse.rb