Question: Problem 6 ( Calculation with Lambda Expressions ) . For each of the following, write a lambda expression to calculate the function. You can use

Problem 6(Calculation with Lambda Expressions). For each of the following, write a lambda
expression to calculate the function. You can use any of the functions I covered in class or in the slides,
but you should not use recursion for any of the functions. For all questions the functions are for
numbers represented as Church numerals.
a. ONETRUE =(!a.!b.!c.......) should calculate ONETRUE a b c defined as follows
1. ONETRU fls fls fls = fls
2. ONETRU fls fls tru = tru
3. ONETRU fls tru fls = tru
4. ONETRU fls tru tru = fls
5. ONETRU tru fls fls = tru
6. ONETRU tru fls tru = fls
7. ONETRU tru tru fls = fls
8. ONETRU tru tru tru = fls
b. sum_products =(!n.......) should calculate 1*2+3*4+5*6+ n*(n+1)
c. DIV3= integer division by 3.
Examples DIV32=0
DIV35=1
MOD36=2
MOD37=2
e.(Bonus) Can you generalize this for integer division by n?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!