RosettaCodeData/Task/Y-combinator/Groovy/y-combinator-2.groovy
2023-07-01 13:44:08 -04: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
}