Module: Glymour::StructureLearning::PowerSet
- Defined in:
- lib/glymour.rb
Instance Method Summary collapse
- #power_set ⇒ Object
-
#power_set! ⇒ Object
Sets an array to its “power array” (array of subarrays).
Instance Method Details
#power_set ⇒ Object
82 83 84 |
# File 'lib/glymour.rb', line 82 def power_set return clone.power_set! end |
#power_set! ⇒ Object
Sets an array to its “power array” (array of subarrays)
74 75 76 77 78 79 80 |
# File 'lib/glymour.rb', line 74 def power_set! return [[]] if empty? first = shift rest = power_set! rest + rest.map {|subset| [first] + subset } end |