cartesian.groovy
(372 bytes)
public List cartesian(Collection... collections) { collections = collections.collect { collection -> collection.collect { [it] } } def result = collections.first() collections.drop(1).each { collection -> result = result.collect { left -> collection.collect { right -> left + right } }.sum() } return result }
Powered by dragos-matei.sorescu.eu