RosettaCodeData/Task/Y-combinator/Groovy/y-combinator-2.groovy
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

7 lines
200 B
Groovy

def Y = { le -> ({ f -> f(f) })({ f -> le { Object[] args -> f(f)(*args) } }) }
def mul = Y { mulStar -> { a, b -> a ? b + mulStar(a - 1, b) : 0 } }
1.upto(10) {
assert mul(it, 10) == it * 10
}