Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A polynomial could be represented by a list of pairs where each pair coefficient and an exponent. For example, the list ' ( ( 1

A polynomial could be represented by a list of pairs where each pair coefficient and an exponent. For example, the list '((1.3)(2.2)(3.1)(4.0)) represents the polynomial x +2x^2+3x +4.
a. Write a Scheme function called (eval-poly p x) that evaluates the polynomial p for value x
>(define poly1'((1.3)(2.2)(3.1)(4.0)))
>(define poly2'((2.2)(4.1)(5.0)))
>(eval-poly poly11)
10
>(eval-poly poly13)
58
>(eval-poly poly22)
21
>(eval-poly poly2
7)
131
b. Write a Scheme function called (get-poly-fun p) that returns a function that takes a single parameter which evaluates polynomial p at that value.
>((get-poly-fun poly1)10)
1234
>((get-poly-fun poly1)1)
10
>(define f1(get-poly-fun poly1))
>(define f2(get-poly-fun poly2))
>(f13)
58
>(f22)
21
>(f27)
131

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions