class method
SyntaxSuggest::CodeFrontier.combination
combination(array)
lib/syntax_suggest/code_frontier.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/syntax_suggest/code_frontier.rb, line 162
def self.combination(array)
guesses = []
1.upto(array.length).each do |size|
guesses.concat(array.combination(size).to_a)
end
guesses
end
Example:
Example
combination([:a, :b, :c, :d]) # => [[:a], [:b], [:c], [:d], [:a, :b], [:a, :c], [:a, :d], [:b, :c], [:b, :d], [:c, :d], [:a, :b, :c], [:a, :b, :d], [:a, :c, :d], [:b, :c, :d], [:a, :b, :c, :d]]