Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you will be learning Scheme through the use of DrRacket. We start with some basic concepts; trying to understand prefix notation and
In this assignment, you will be learning Scheme through the use of DrRacket. We start with some basic concepts; trying to understand prefix notation and using procedures in Scheme. You may only use the procedures shown in the text and slides also see below for three prohibited forms in this assignment - not any of the additional library procedures in R5RS Scheme. Solve the following questions in the .rkt template provided.
Do not use the display, write, or begin forms in your solutions. 1. Using DrRacket to compute the following expressions. 1.11.21.31.41.592+55(6+12+5)257((5(13))+(24))3(4+(((66)+(66))/(10+2)))((((((4+6)(6+4))/2)/2)5)/2)+((((45)+(54))/2)+(45)) Your program should contain code to compute these expressions as given above. Don't give the results as constants. 2. Define a procedure "add" that takes two parameters and returns the sum of them. 3. Define a recursive procedure called "square" that will compute the square amount of a value by calling the "add" procedure defined in the previous question. You may not use the multiplication operator. 3.1 You must use the add procedure defined above. 3.2 You will need to account for negative values as well. 3.3 Use comments to indicate which code represents the four steps of the fantastic abstract approach, respectively: ; The code for size-n problem is: ; The code for stopping condition and its return value are: ; The code for size-m problem is: ; The code for constructing size-n problem is: Hint: This will require a conditional and possibly the (absx) procedure. Note, you can use this formula to identify your size- (n1) problem: n2=1+3+5++(n+n1). >(square5)25>(square-7)49 If you need to create a helper procedure, please name it square-helper. 4. Define a procedure "read-for-square" to read a value for the square procedure defined above. This procedure takes no parameters and will take an input value from keyboard and pass to the Square procedure defined above. > (read-for-square) ; enter 5 from keyboard 25 5. Define a procedure "diff-squares" that will compute the difference between the square values of 2 inputs. You must implement the read-for-square procedure defined above. This procedure should never return a negative value, as it should return the absolute value. >(diff-squares)51075;input;input;output 6. Create a recursive procedure called (sum-odds max), where max is a number. The procedure should return the sum of all positive odd numbers up to and including max. For example: (sumodds 10) should give 25. (Hint: you can check if a number is odd using the form odd?) 7. Create a recursive procedure called (fib a) to compute terms in the Fibonacci sequence: given a, find the a'th Fibonacci number. Sample output: (fib 0) should give 0, (fib 9) should give 34Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started