Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SCHEME LANGUAGE Write Scheme denitions for the functions below. Use the interpreter to try them out on a couple of test cases to check that

SCHEME LANGUAGE

Write Scheme denitions for the functions below. Use the interpreter to try them out on a

couple of test cases to check that they work, and include this output with your solutions.

NOTE: Scheme provides built-in support for exponentiation (via the expt function, dened so

that (expt x y) yields xy). For the exercises below, however, please construct the functions

x 7! xk using only and function application.

(a) cube, the function cube(x) = x3.

(b) p, the polynomial function p(x) = (x5 + 11x4 + 24x3 x + 21)3.

(Hint: Of course it is possible to expand (x5 + 11x4 + 24x3 x + 21)3 as a polynomial

of degree 15 and write a Scheme function to compute this by brute force. You can avoid

much of this computation by dening p in stagesrst dene the polynomial q(x) =

x5 + 11x4 + 24x3 x + 21 as a Scheme function; now use this function to dene p.)

(c) Using your function cube, write the function tenth(x) = x10.

(d) Using the function tenth, write the function hundredth(x) = x100. Recall that 100 =

10 10.

(e) How might you check to see whether your hundredth function gives you the right answer?

(f) Reect on your denition of hundredth above. What would have been the di-culty of

dening this merely in terms of ?

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

Step: 3

blur-text-image

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

More Books