RosettaCodeData/Task/Combinations/E/combinations.e

14 lines
286 B
Text
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
def combinations(m, range) {
return if (m <=> 0) { [[]] } else {
def combGenerator {
to iterate(f) {
for i in range {
for suffix in combinations(m.previous(), range & (int > i)) {
f(null, [i] + suffix)
}
}
}
}
}
}