6 lines
203 B
Groovy
6 lines
203 B
Groovy
def powerSetRec(head, tail) {
|
|
if (!tail) return [head]
|
|
powerSetRec(head, tail.tail()) + powerSetRec(head + [tail.head()], tail.tail())
|
|
}
|
|
|
|
def powerSet(set) { powerSetRec([], set as List) as Set}
|