I'm trying to do SICP exercise 2.6 in swift which is about church numerals
The zero is defined in scheme as
(define zero (lambda (f) (lambda (x) x)))
converted to swift closure I think is
let zeroR = {(x:Int)->Int in return x}
let zero = {(f:(Int)->Int)->(Int)->Int in return zeroR}
But the problem is the definition of add-1 which is in scheme
(define (add-1 n)
(lambda (f) (lambda (x) (f ((n f) x)))))
I can't convert this to swift closure version yet. Some idea?
Thanks.