Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explain the essence and the mode of operation of function defined in the image below Compare it with function defined below List and explain all

Explain the essence and the mode of operation of function defined in the image below

image text in transcribed

Compare it with function defined below

image text in transcribed

List and explain all essential similarities and differences between these two.

To test whether a Church numeral is zero, we must find some appropriate pair of arguments that will give us back this information-specifically, we must apply our numeral to a pair of terms zz and ss such that applying ss to zz one or more times yields fls, while not applying it at all yields tru. Clearly, we should take zz to be just tru. For ss, we use a function that throws away its argument and always returns fls: pair co Co pair co Ci opy/1 pairci c2 copy/1 pair cz c3 copy/1 pair ca ca Figure 5-1: The predecessor function's "inner loop" iszro CI iszro (times co c) Surprisingly, subtraction using Church numerals is quite a bit more difficult than addition. It can be done using the following rather tricky "predecessor function," which, given Co as argument, returns co and, given , returns c: zz-pair co Co ss. p. pair (snd p) (plus cl (snd p)); prd Am. fst (m ss zz); This definition works by using m as a function to apply m copies of the func tion ss to the starting value zz. Each copy of ss takes a pair of numerals pair c.cj as its argument and yields pair cj Cj+1 as its result (see Figure 5. 1) So applying ss, m times, to pair co Co yields pair co Co when m 0 and pair Cm-1 Cm when m is positive. In both cases, the predecessor of m is found in the first component. cc-An. As. Az. s (n s z): The term scc is a combinator that takes a Church numeral n and returns another Church numeral that is, it yields a function that takes arguments s and z and applies s repeatedly to z. We get the right number of applications of s to z by first passing s and z as arguments to n, and then explicitly applying s one more time to the result. To test whether a Church numeral is zero, we must find some appropriate pair of arguments that will give us back this information-specifically, we must apply our numeral to a pair of terms zz and ss such that applying ss to zz one or more times yields fls, while not applying it at all yields tru. Clearly, we should take zz to be just tru. For ss, we use a function that throws away its argument and always returns fls: pair co Co pair co Ci opy/1 pairci c2 copy/1 pair cz c3 copy/1 pair ca ca Figure 5-1: The predecessor function's "inner loop" iszro CI iszro (times co c) Surprisingly, subtraction using Church numerals is quite a bit more difficult than addition. It can be done using the following rather tricky "predecessor function," which, given Co as argument, returns co and, given , returns c: zz-pair co Co ss. p. pair (snd p) (plus cl (snd p)); prd Am. fst (m ss zz); This definition works by using m as a function to apply m copies of the func tion ss to the starting value zz. Each copy of ss takes a pair of numerals pair c.cj as its argument and yields pair cj Cj+1 as its result (see Figure 5. 1) So applying ss, m times, to pair co Co yields pair co Co when m 0 and pair Cm-1 Cm when m is positive. In both cases, the predecessor of m is found in the first component. cc-An. As. Az. s (n s z): The term scc is a combinator that takes a Church numeral n and returns another Church numeral that is, it yields a function that takes arguments s and z and applies s repeatedly to z. We get the right number of applications of s to z by first passing s and z as arguments to n, and then explicitly applying s one more time to the result

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago