# Scheme Functions 4.0

##### Part I, Polynomials

A data abstraction for polynomials was discussed in class. Create the file

*[url removed, login to view]* and implement the following:

1. Constant **zp**. The zero polynomial.

2. Procedure **degree**.

(degree p) ; returns the degree of polynomial *p*

3. Procedure **lc**.

(lc p) ; returns the leading coefficient for polynomial *p*

4. Procedure **prest**.

(reset p) ; returns the rest of polynomial *p* except leading term.

5. Constructor **pcons**.

(pcons n a p) ; returns polynomial created from *a*xn and polynomial *p*

Note! The underlying implementation must use a list of 2-element vectors

to represent the polynomial. Zero terms should not be included.

6. Procedure **mt**.

(mt d c) ; returns term created as *c*xd

7. Procedure **lt**.

(lt p) ; returns the leading term from polynomial *p*.

8. Procedure **p+**.

(p+ p1 p2) ; returns the sum of polynomials *p1* and *p2*.

9. Procedure **p***.

(p* p1 p2) ; returns the product of polynomials *p1* and *p2*.

10. Procedure **np**.

(np p) ; returns the negation for polynomial *p*.

11. Procedure **p-**.

(p- p1 p2) ; returns the difference of polynomials *p1* and *p2*.

12. Procedure **v**.

(v p n) ; returns the value of polynomial *p* when *x* is equal to *n*.

## Deliverables

Part II, Binary Numbers. Implement the binary number functions discussed in class. Create the file

*[url removed, login to view]* for the following:

1. Procedure **d->p**

Parameter: list of binary digits

Return: polynomial of degree 1 less than number of digits with

digits as coefficients

2. Procedure **binary->decimal**

Parameter: list of digits representing a binary number

Return: decimal value

3. Procedure **p->d**

Parameter: decimal number

Return: list of digits in binary representation

4. Procedure **decimal->binary**

Parameter: decimal value

Return: list of digits representing the binary equivalent

Part III, Number Conversion

Implement the number conversion functions listed below. Create the file *[url removed, login to view]* for the following:

Look over the programs for **b->d** and **d->b** and determine what changes have to be made to get definitions for the four procedurs:

octal->decimal

decimal->octal

Since we are representing our hexadecimal numbers as lists of digits, we can use the number 10 for *A*, 11 for *B*, and so on, so that (12 5 10) is the list representation of the hexadecimal number *C5A*. Define one pair of conversion procedures **base->decimal** and **decimal->base** that takes two arguments, the number to be converted and the base, where the base can be any positive integer Then define a procedure **change-base** that changes a number *num* from base *b1* to base *b2*, where *num* is a list of digits. Thus *(change-base num b1 b2)* is a list of digits that gives the base *b2* representation of *num*. The following are some examples:

(change-base '(5 11) 16 8) => (1 3 3)

(change-base '(6 6 2) 8 2) => (1 1 0 1 1 0 0 1 0)

(change-base '(1 0 1 1 1 1 1 0 1) 2 16) => (1 7 13)

## Platform

Write Scheme source code for the above functions. The requried interpreter is SISC Version 1.8.7 which can be downloaded free from [url removed, login to view]

Below are a few restrictions that have to be kept in mind when writing code.

1)

Each of the functions must be specified using the full *lambda expression* to emphasize that they are first class entities in the language.

2)If you decide to use *define* anywhere in your code it is to be used for values bound at the top-level only. Local functions should be declared using *let* or one of its variants.

The attached zip file has the specifications and requirements for the project in case anything is hard to read.

**THE DUE DATE FOR THIS IS MONDAY MAY 3RD 04**. **_HE DUE DATE FOR THIS IS MONDAY MAY 3RD 04_**.

Habilidades: Engenharia, MySQL, PHP, Arquitetura de software, Teste de Software

( 27 comentários ) United States

ID do Projeto: #3188942

## Concedido a:

milan077

See private message.

\$21.25 USD em 7 dias
(17 Comentários)
4.1

## 2 freelancers estão ofertando em média \$53 para esse trabalho

AnthonysWeb

See private message.

\$85 USD in 7 dias
(11 Comentários)
4.1