Created
February 24, 2011 01:20
-
-
Save jewel12/841567 to your computer and use it in GitHub Desktop.
順序を保持した組み合わせ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class Array | |
def comb | |
n = self.length - 1 | |
0.upto(n) do |head_n| | |
head_n.upto(n) {|tail_n| yield self[head_n..tail_n] } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment