Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You can use the following functions from the SML Basis Library, but not any others. http://sml-family.org/Basis/top-level-chapter.html http://sml-family.org/Basis/list.html http://sml-family.org/Basis/list-pair.html 4. Let us represent a polynom ao

image text in transcribed

You can use the following functions from the SML Basis Library, but not any others.

http://sml-family.org/Basis/top-level-chapter.html http://sml-family.org/Basis/list.html http://sml-family.org/Basis/list-pair.html

4. Let us represent a polynom ao +aa22 +...+anz" (n 2 -1) by the list (ao, a1,a2,..., anl of its coefficents. (Notice that we list the coefficients in the ascending order of their degree; the head element of the list is the coefficient of degree 0 etc.) (i) Code a function evalPoly real list -> real -> real that returns the value of a given polynom for a given value of r - evalPoly [4.0,3.0,8.0] 10.0; val it-834.0: real; (ii) Code a function addPoly : real list ->real list -> real list that adds two polyno- mials. (This works like long addition of decimal representations natural numbers, except that you do not have to worry about carries.) addPoly [3.0,5.0,4.0] [40.0,30.0,80.0,90.0] val it -[43.0,53.0,84.0,90.0] : real list; (iii) Code a function multPoly : real list -> real list -> real list that multiplies two polynomials. (This works like long multiplication of decimal representations natural numbers, except that you do not have to worry about carries.) - multPoly [2.0,3.0,5.0] [7.0,9.0] - [14.0,39.0,62.0,45.0]; val it - [14.0,39.0,62.0,45.0]real list 4. Let us represent a polynom ao +aa22 +...+anz" (n 2 -1) by the list (ao, a1,a2,..., anl of its coefficents. (Notice that we list the coefficients in the ascending order of their degree; the head element of the list is the coefficient of degree 0 etc.) (i) Code a function evalPoly real list -> real -> real that returns the value of a given polynom for a given value of r - evalPoly [4.0,3.0,8.0] 10.0; val it-834.0: real; (ii) Code a function addPoly : real list ->real list -> real list that adds two polyno- mials. (This works like long addition of decimal representations natural numbers, except that you do not have to worry about carries.) addPoly [3.0,5.0,4.0] [40.0,30.0,80.0,90.0] val it -[43.0,53.0,84.0,90.0] : real list; (iii) Code a function multPoly : real list -> real list -> real list that multiplies two polynomials. (This works like long multiplication of decimal representations natural numbers, except that you do not have to worry about carries.) - multPoly [2.0,3.0,5.0] [7.0,9.0] - [14.0,39.0,62.0,45.0]; val it - [14.0,39.0,62.0,45.0]real list

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

What is fuzz? Explain Zinssers notion of fuzz with a few examples.

Answered: 1 week ago

Question

love of humour, often as a device to lighten the occasion;

Answered: 1 week ago

Question

orderliness, patience and seeing a task through;

Answered: 1 week ago

Question

well defined status and roles (class distinctions);

Answered: 1 week ago