Ruby/Array/combination

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

Iterate all possible 2-element subsets (order does not matter)

a = [1,2,3]
a.rubination(2) {|x| print x }  # Prints "[1, 2][1, 3][2, 3]"