Ruby/Array/product
Материал из Wiki.crossplatform.ru
Версия от 18:00, 13 сентября 2010; ViGOur (Обсуждение | вклад)
Return the Cartesian product of the two sets
a = [1,2,3] a.product(["a","b"]) # => [[1,"a"],[1,"b"],[2,"a"],[2,"b"],[3,"a"],[3,"b"]] [1,2].product([3,4],[5,6]) # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6], etc... ]