church-encoding

Closures and universal quantification

I've been trying to work out how to implement Church-encoded data types in Scala. It seems that it requires rank-n types since you would need a first-class const function of type forAll a. a -> (forAll b. b -> b). However, I was able to encode pairs thusly: import scalaz._ trait Compose[F[_],G[_]] { type Apply = F[G[A]] } trait Closu...

How can I make Church numerals more human readable in lisp?

I can define church numerals fairly easy using scheme: > (define f (lambda (x) x)) > (f f) ;0 #<procedure:f> > (f (f f)) ;1 #<procedure:f> However, this doesn't make it very easy to recognize that (f f) is 0 and (f (f f)) is 1. Is there a way that I can make these numerals more readable? What would be ideal is this: > (f f) 0 > (f ...

Church numeral for addition

Hi All, I am stuck up at the following step. It will be great if someone can help me out: 2 = λfx.f(f x) 3 = λfx.f(f(f x)) ADD = λm n f x. m f (n f x) My steps are: (λm n f x. m f (n f x)) (λf x.f(f(f x))) (λf x.f(f x)) -> ((λn f x. (λf x.f(f(f x))) f (n f x))) (λf x.f(f x)) -> ((λf x. (λf' x'.f'(f'(f' x'))) f ((λf" x".f"(f" x"))...