Question: 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.
The exact question to solve is down below, example on how to solve it
ex: 3 + 5 - 7 ( (- (+ 3 5) 7)) <------- This is what i am looking for
1. Using Dr. Racket to compute the following expressions. [5 points] 1.1 19 * 12 + 25 - 33 1.2 15 * ( 16 + 5 / 3 ) - 12 * 7 1.3 121 * (( 15 - ( 4 * 3 )) + ( 19 / 4 ) ) * 14 1.4 (22 + 33) * ( 21 + ( ( ( 15 / 6 ) + ( 3 * 4 ) ) / ( 5 - 7 ) ) ) 1.5 ( ( ( ( ( ( 6 - 9 ) * ( 11 * 5 + 7 ) ) / 2 ) / 2 ) 5 ) / 3 ) + ( ( ( ( 7 * 5 ) + ( 8 / 2 * 4 ) ) / 2 ) + ( 9 * 5 ) )
2 Bind (define) each value in question 1.5 above to its English text and then change the expression using the defined names. [5 points]
For example, the expression 8 + 2 - 10 should be replaced with names eight, two, and ten, and the correct corresponding expression is (eight + two - ten), of course, in prefix notation.
Define a procedure called Subtract that takes two parameters and returns the difference of them. You can use the built-in - to define your Subtract procedure. [5 points]
> (Subtract 120 50)
70
4- 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 that you defined in question 3.
(1) You must recursion to implement the iteration.
(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. [10 points]
> (IntDivide 8 3)
2
> (IntDivide 8 -3)
-2
5- 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 IntDivide procedure. [5 points]
> (ReadForIntDivide)
-25
4
-6
6- 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. [5 points] (1) You can use the built-in + operation, but you cannot use the built-in *. You must recursively use addition to solve the problem.
(2) You will need to account for negative values as well.
> (Multiply 8 3)
24
7- 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. You cannot use the built-in operations -, /, and *.
> (DiffDivide 8 3)
2
8 - Re-implement the procedure (DiffDivide x y) and call it (DiffDivideLet x y). In this procedure, you must use let-form to bind all the procedures used in the definition: Subtract, IntDivide, and Multiply. You may name the local name whatever youd like. [10 points]
> (DiffDivideLet 8 3)
2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
