RosettaCodeData/Task/Y-combinator/Groovy/y-combinator-2.groovy

8 lines
200 B
Groovy
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
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
}