Skip to content

Instantly share code, notes, and snippets.

@hrstt
Created August 30, 2011 08:17
Show Gist options
  • Save hrstt/1180451 to your computer and use it in GitHub Desktop.
Save hrstt/1180451 to your computer and use it in GitHub Desktop.
Ruby: 配列同士の総当り組み合わせ
# 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