class Set

Public Instance Methods

power_set() click to toggle source

@author Phrogz

# File lib/facets/set.rb, line 7
def power_set
  if empty?
    Set[self]
  else
    any_value = [to_a.first]
    subsubs = (self - any_value).power_set
    subsubs + subsubs.map{ |subset| subset + any_value }
  end
end