Module: Enumerable

Defined in:
lib/vine.rb

Instance Method Summary collapse

Instance Method Details

#segmentation(n) ⇒ Object



3
4
5
6
7
# File 'lib/vine.rb', line 3

def segmentation(n)
  0.upto(size - 2).to_a.combination(n - 1).to_a.map do |s|
    [-1, * s, size - 1].each_cons(2).map {|i, j| self[(i + 1)..j] }
  end
end