Top Level Namespace
Defined Under Namespace
Modules: Thoreau
Instance Method Summary collapse
Instance Method Details
#combos_of(entries) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/thoreau/service/util.rb', line 1 def combos_of(entries) return [{}] if entries.size == 0 first_response = entries.first.map { |x| { x[0] => x[1] } } return first_response if entries.size == 1 combos_of_rest = combos_of(entries.slice(1..(entries.size))) first_response.flat_map do |f| combos_of_rest.map { |r| r.merge(f) } end end |