Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4 [20pt] In the Church encoding of natural numbers, we have used the n-fold composition of f, written f. Intuitively, f means applying function

image text in transcribed

Problem 4 [20pt] In the Church encoding of natural numbers, we have used the n-fold composition of f, written f". Intuitively, f means applying function f for n times. a) (5pt) Implement a function funPower, which takes a function f, an integer n and returns the function ". For example, (funPower sqrt 2) 16) should return 2. n. For example, (encode 2) should return 2 (i.e., the function . : f (/1). returns n. For example, (decode (encode 2)) should return 2. of ni x n2 (i.e. , "] X n2). For example, (decode (MULT (encode 2) (encode 3) should be 6. b) (5pt) Implement a function encode, which takes a natural number n and returns the church encoding of c) (5pt) Implement a function decode, which takes n (the church encoding of some natural number n) and d) (5pt) Implement a function MULT, which takes two church numbers n1, n2 and returns the church number Problem 4 [20pt] In the Church encoding of natural numbers, we have used the n-fold composition of f, written f". Intuitively, f means applying function f for n times. a) (5pt) Implement a function funPower, which takes a function f, an integer n and returns the function ". For example, (funPower sqrt 2) 16) should return 2. n. For example, (encode 2) should return 2 (i.e., the function . : f (/1). returns n. For example, (decode (encode 2)) should return 2. of ni x n2 (i.e. , "] X n2). For example, (decode (MULT (encode 2) (encode 3) should be 6. b) (5pt) Implement a function encode, which takes a natural number n and returns the church encoding of c) (5pt) Implement a function decode, which takes n (the church encoding of some natural number n) and d) (5pt) Implement a function MULT, which takes two church numbers n1, n2 and returns the church number

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

LO2 Identify components of workflow analysis.

Answered: 1 week ago