CSE 240 Homework 11, Fall 2016 (50 points)
CSE 240 Homework 11, Fall 2016 (50 points)
Due Saturday, November 5, 2016 at 11:59PM, plus a 24-Hour grace period
Introduction
The aim of this assignment is to make sure that you understand and are familiar with the concepts covered in the lectures. By the end of the assignment, you should have
- strong concept functional paradigm.
- strong concept Dr. Racket.
- Understood names and procedures
Reading: Text Chapter 4 and course notes (slides). This is a complete new language, and you need to spent more time to read and to program.
Preparation: Complete the multiple choice questions in the textbook exercise section. The answer keys can be found in the course Web site. These exercises can help you prepare for your weekly quiz and the exam. You are encouraged to read the other exercise questions and make sure you understand these questions in the textbook exercise section, which can help you better understand what materials are expected to understand after the lectures and homework on each chapter.
You are expected to do the majority of the assignment outside the class meetings. Should you need assistance, or have questions about the assignment, please contact the instructor or the TA during their office hours.
You are encouraged to ask and answer questions on the course discussion board. However, do not share your answers and codein the course discussion board.
Practice Exercises (no submission required)
1 Tutorial: Getting Started with DrRacket
1.1 To complete this assignment, you will need to download and install a copy of Dr Racket (http://racket-lang.org/download/) on your local PC.
1.2 Start the program DrRacket.
1.3 Choose the “R5RS” from the language menu:
DrRacket menu: language à choose language àOther Languages – R5RS.
1.4 Enter your programs/forms in the upper window of DrRacket and click on the “run” button to execute your programs/forms, e.g., enter:
(write “hello world”) (display “hello world”)
(newline) (newline)
(write (+ (* 3 8) 10)) (display (+ (* 3 8) 10))
(- 20 5) (- 20 5)
(write (read)) (display (read)) ; input a number from keyboard
Click on run, the following results should appear in the lower window:
hello world
34
15
2 Use DrRacket to calculate the following expressions/forms.
(1) (2 + (4 + (6 + (8 + (10 + 12))))).
(2) (((((2 + 4) + 6) + 8) + 10) + 12)
(3) ((2 + 4) + (6 + 8) + (10 + 12))
(4) (2 + 4 + 6 + 8 + 10 + 12)
(5) (2 + 4 * 6 + 8 * 10 + 12)
(6) 125187
(7) Input two integers: (+ (read) (read))
3 Write Scheme programs/forms to
(1) find the second element of the list ‘(2 4 6 8 10 12). Your form should work for any list containing two or more elements.
(2) find the last element of the list ‘(2 4 6 8 10 12). Your form only needs to work for lists of six elements.
(3) merge the two lists ‘(1 2 3 4) and ‘(5 7 9) into a single list ‘(1 2 3 4 5 7 9)
(4) obtain the length of the list ‘(a b x y 10 12)
(5) check whether ‘(+ 2 4) is a symbol
(6) check whether ‘+ is a member of the list ‘(+ 3 4 6)
(7) check whether “+”, ‘(+ 3 5), “(* 4 6)” are strings
(8) check whether (* 3 5), ‘(/ 3 7), (1 2 3 4), “(+ 2 8) and “( 1 2 3)” are strings
Programming Exercise (50 points)
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 a few simple procedures. You may only use the procedures shown in the text and slides – not any of the additional library procedures in Scheme.
- Using
Dr. Racket, compute the following expressions. [5
points]
- 8 + 2 – 10
- 2* (5 + 10 + 5 ) – 30
- 2 * ( ( 2 * 4 ) + ( 2 + ( 0 * 5 ) ) )
- 3 * ( 4 + ( ( ( 6 * 6 ) + ( 6 * 6 ) ) / ( 10 + 2 ) ) )
- ( ( ( ( ( ( 4 + 6 ) * ( 6 + 4 ) ) / 2 ) / 2 ) – 5 ) / 2 ) + ( ( ( ( 4 * 5 ) + ( 5 * 4 ) ) / 2 ) + ( 4 * 5 ) )
- Bind (define) each value in 1.5 above to its’ English text. For example, the values in 1.1 should be replaced with variables with the correct corresponding value (eight + two – ten). [5 points]
- Define a procedure “Add” that takes parameters and returns the sum of them. [5 points]
- Define
a recursive procedure called “Square” that will compute the square amount of a
value by additions.
- You must use theAdd procedure defined above.
- 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 multiplication in this procedure definition. [15 points]
- Define a procedure “ReadForSquare” to read a value for the Square procedure defined above. This procedure takes no values and will pass an input value to the Square procedure. [5 points]
- Define a procedure “DiffSquares” that will compute the difference between the square values of 2 inputs. You mustimplement the ReadForSquare procedure defined above. This procedure should never return a negative value, it should return the absolute value. [10 points]
- Re-implement the procedure Add and call it “AddLet”. In this procedure, you must implement let-form to bind values. You may name the variables whatever you’d like. [5 points]
Grading of Programming Assignment
The TA will grade your program following these steps:
(1) Compile the code. If it does not compile, 20% of the points given will be deducted. For example, if there are 20 points possible, you will earn 16 points if the program fails to compile.
(2) The TA will read your program and give points based on the points allocated to each component, the readability of your code (organization of the code and comments), logic, inclusion of the required functions, and correctness of the implementations of each function.
What to Submit?
You are required to submit your solutions in a compressed format (.zip). Zip all files into a single zip file. Make sure your compressed file is labeled correctly – lastname_firstname11.zip.
For this home assignment, the compressed file MUST contain the following:
hw11.rkt (Scheme program)
No other files should be in the compressed folder.
If multiple submissions are made, the most recent submission will be graded, even if the assignment is submitted late.
Where to Submit?
All submissions must be electronically submitted to the respected homework link in the course web page where you downloaded the assignment.
Late submission deduction policy
- No penalty for late submissions that are received within 24 hours after the deadline;
- 10% grade deduction for every day it is late after the grace period;
- No late submission after Tuesday at 11:59PM.
Academic Integrity and Honor Code.
You are encouraged to cooperate in study group on learning the course materials. However, you may not cooperate on preparing the individual assignments. Anything that you turn in must be your own work: You must write up your own solution with your own understanding. If you use an idea that is found in a book or from other sources, or that was developed by someone else or jointly with some group, make sure you acknowledge the source and/or the names of the persons in the write-up for each problem. When you help your peers, you should never show your work to them. All assignment questions must be asked in the course discussion board. Asking assignment questions or making your assignment available in the public websites before the assignment due will be considered cheating.
The instructor and the TA will CAREFULLY check any possible proliferation or plagiarism. We will use the document/program comparison tools like MOSS (Measure Of Software Similarity: http://moss.stanford.edu/) to check any assignment that you submitted for grading. The Ira A. Fulton Schools of Engineering expect all students to adhere to ASU’s policy on Academic Dishonesty. These policies can be found in the Code of Student Conduct:
ALL cases of cheating or plagiarism will be handed to the Dean’s office. Penalties include a failing grade in the class, a note on your official transcript that shows you were punished for cheating, suspension, expulsion and revocation of already awarded degrees.
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"
