Created
August 30, 2011 08:17
-
-
Save hrstt/1180451 to your computer and use it in GitHub Desktop.
Ruby: 配列同士の総当り組み合わせ
This file contains hidden or 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
# Array#map | |
def cross(a, b) | |
a.map{|elem_a| b.map{|elem_b| elem_a.to_s + elem_b.to_s}}.flatten | |
end | |
# Array#product | |
def cros(a,b) | |
a.product(b).map{|elem| elem.join()} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment