check library: https://github.com/jarekratajski/badlam code: val identity:Lambda = (x) => x println(SmartDisplay.web.display(identity)) val aTrue:Lambda = (x) => (y) => x println("true ~ " + SmartDisplay.web.display(aTrue)) val aFalse:Lambda = (x) => (y) => y println("false ~ " + SmartDisplay.web.display(aFalse)) val and:Lambda = (p) => (q) => p(q)(p) println("and ~ " + SmartDisplay.webP.display(and)) val result1:Lambda = and (aFalse) (aTrue) println("resutlt1 ~ " + SmartDisplay.web.display(result1)) val or:Lambda = (p) => (q) => p(p)(q) println("or ~ " + SmartDisplay.webP.display(or)) val result2:Lambda = or(aFalse) (aTrue) println("result2 ~ " + SmartDisplay.web.display(result2)) val not:Lambda = (p) => (a) => (b) => p(b)(a) println("not false ~ " + SmartDisplay.web.display(not(aFalse))) println("toJVMBoolean(result2) = " + pl.setblack.badlam.Boolean.toBoolean(result2)) val aTrue:Lambda = (x) => (y) => x val aFalse:Lambda = (x) => (y) => y val zero:Lambda = f=> x => x val one:Lambda = f=> x => f(x) val two:Lambda = f=> x => f(f(x)) val succ:Lambda = (n) => (f) => (x) => f(n(f)(x)) val mult:Lambda = (m) => (n) => (f) => m(n(f)) val pred:Lambda = (n) => (f) => (x) => n((g) => (h) => h(g(f)))((u) => x)((u) => u) val ifLambda:Lambda = (c) => (t) => (f) => c(t)(f)((x) => x) val isZero:Lambda = (n) => n((x) => aFalse)(aTrue) val autocall:Lambda = (x) => x(x) val Y:Lambda = (f) => autocall((y) => f((v) => y(y)(v))) val G:Lambda = (r) => (n) => (ifLambda(isZero(n)) ((x) => one) ((x) => mult(n)(r(pred(n)))) ) val fact = Y(G) val a:Lambda = f=>x => f(f(f(f(f(x))))) //5 println("a ~ " + SmartDisplay.webF.display(a)) val result = fact(a) println("a! ~ " + SmartDisplay.webF.display(result))