class church static function zero() return || -> (|x| -> x) end static function succ(c) return |f| -> (|x| -> f(c(f)(x))) end static function add(c, d) return |f| -> (|x| -> c(f)(d(f)(x))) end static function mul(c, d) return |f| -> c(d(f)) end static function pow(c, e) return e(c) end static function fromint(n) local ret = zero() if n > 0 then for i = 1, n do ret = succ(ret) end end return ret end static function toint(c) return c(|x| -> x + 1)(0) end end local three = church.succ(church.succ(church.succ(church.zero()))) local four = church.succ(three) print($"three -> {church.toint(three)}") print($"four -> {church.toint(four)}") print($"three + four -> {church.toint(church.add(three, four))}") print($"three * four -> {church.toint(church.mul(three, four))}") print($"three ^ four -> {church.toint(church.pow(three, four))}") print($"four ^ three -> {church.toint(church.pow(four, three))}")