Sha256: a0cfd2d11a1ba58a452d90bd176da3049d3ee6028c8e77382b2ee9c57a6d92a9
Contents?: true
Size: 497 Bytes
Versions: 2
Compression:
Stored size: 497 Bytes
Contents
module Rankum module Utils module FCPPair class Rankum::Utils::Pair < Struct.new(:actual, :next); end def self.to_a(rank) rank.each_with_index.inject([]) do |pairs, (item, idx)| rank[(idx + 1)..-1].each { |next_item| pairs << Pair.new(item, next_item) } pairs end end def self.to_h(rank) to_a(rank).inject(Hash.new(0)) do |pairs, item| pairs[item] += 1 pairs end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rankum-1.1.0 | lib/rankum/utils/fcp_pair.rb |
rankum-1.0.0 | lib/rankum/utils/fcp_pair.rb |