Create a λ-Term fold
that, when applied to a Church nat N, a function F, an initial value X, and a Church N-Tuple, performs a right-fold over the N-tuple. In other words, create a generic fold<N,F,X,t>
function for N-tuples. Example:
- (fold λf.λx.(f x) F X λt(t 1)) == (F 1 X)
- (fold λf.λx.(f (f x)) F X λt(t 1 2)) == (F 1 (F 2 X))
- (fold λf.λx.(f (f (f x))) F X λt(t 1 2 3)) == (F 1 (F 2 (F 3 X)))
Your final answer must be a λ-Term that implements fold
correctly, as follows: