Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will be learning Scheme through the use of Dr. Racket. We would like to start with some basic concepts; trying to

In this assignment, you will be learning Scheme through the use of Dr. Racket. We would like to start with some basic concepts; trying to under prefix notation and the use procedure in Scheme. You will also implement nested procedures and recursive procedures. You may only use the procedures shown in the text and slides - not any of the additional library procedures in Scheme. 
A) [10% Spec] Using Dr. Racket to compute the following expressions. 

1) 3 + 5 - 7

2) 2 * ( 8 + 5 + 4 ) - 25

3) 10 - ( ( 3 * 5 ) + ( 2 + ( 0 * 5 ) ) )

4) 5 * ( 4 + ( ( ( 10 + 10 ) + ( 5 * 8 ) ) / ( 10 + 2 ) ) )

5) ( ( ( ( ( ( 3 + 5 ) * ( 6 + 4 ) ) / 2 ) / 2 ) 5 ) / 3) + ( ( ( ( 2 * 10 ) + (5*4))/2)+(4*5))

B) [10% Spec] Bind (define) each value in A - 5 above to its English text and then change the expression using the defined names. For example, the values in A - 1 would be replaced with names three, five, and seven, and the infix version would now read: (three + five - seven). This problem is to get you used to using (define ...)

C) [10% Spec] Define a procedure Subtract that takes parameters and returns the difference of them You can use the built-in - to define your Subtract procedure.

> (Subtract 120 50) 70 D) [20% Spec] Define a recursive procedure called IntDivide that will compute the quotient of x divided by y. You must implement IntDivide procedure by a sequence of Subtract procedures.
 1) You must use the Subtract procedure defined above. 2) You will need to account for negative values as well. 

Hint: This will require a conditional and possibly the (abs x) procedure. You may not use the built-in division or quotient operators in this procedure definition.

> (IntDivide 8 3) 2 

E) [10% Spec] Define a procedure ReadForIntDivide to read the two input values for the IntDivide procedure defined in the previous. This procedure takes no parameters and will pass an input value to the Square procedure.

> (ReadForIntDivide) -25 4 -6 

F) [10% Spec] Define a recursive procedure called Multiply that will compute the product of x times y. You must implement Multiply procedure by a sequence of additions.

 1) You can use the built-in + operation. 2) You will need to account for negative values as well.
> (Multiply 8 3) 24 

G) [10% Spec] Define a procedure (DiffDivide x y) that will compute the following expression: x - (x/y)*y. For example, if x = 8 and y = 3, then, 8 (8/3)*3 = 2

You must use Subtract, IntDivide, and Multiply defined in the previous questions.

> (DiffDivide 8 3) 2 

H) [10% Spec] Write a function/series of functions called explode that will take a string as a parameter and return a list containing the characters of the string. (Hint: think helper function)

> (explode Hello) (H e l l o)

I) [10% Spec] Create a function/series of functions called implode that will take a list as a parameter and return a string containing the list elements. (Hint: think helper function) (Double Hint: this is very much a re-write of H)

> (i (implode (H e l l o))
Hello 

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

Students also viewed these Databases questions

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago