I'm trying to implement church numerals with javascript.(I'm fairly new to lambda calculus and functional programming in js)
this is my code for defining C0 (C0 = λs.λz.z):
c0 = s => z => z
and this is for C1 (C1 = λs.λz.sz):
c1 = s => z => s(z)
and this is for successor function (succ = λn.λs.λz.s(nsz)):
n => s => z => s(n(s)(z))
however when applying both C0 and C1 to this function the same result happens (and both are incorrect):
succ(c1)
-> s => z => s(n(s)(z))
succ(c0)
-> s => z => s(n(s)(z))
what am I doing wrong?
nszshould translate ton(s)(z)instead ofn(s(z)). - Marcelo Camargosucc(c0), you get the same result assucc(c1)because it gives you the string representation of the lambda function still expecting two parameters. - Marcelo CamargoC0callsszero times andC1callssa single time. - Bergi