CSC 160 Fall 2014 Homework 13 (100 points)
Assigned Dec 1, Due MONDAY Dec 8

1) Assignments with time stamps during class time (Mon or Wed 4:15-5:30pm) will be given a grade of ZERO.
2) In the spirit of the pair programming article that you read and summarized in HW5, this week's homework assignment may be done in pairs. If you choose to work in pairs, you must find time outside of class to work together in person at one computer. As per the syllabus, you cannot "pair-off" with the same person more than once during the semester. If you choose to do the assignment in pairs, please submit one copy through Moodle where both last names are used in each file name and both names appear as a comment at the top of each pane (Definitions and Interactions).
3) Start this homework as soon as possible so that you have time to get any help you may need from the instructor or course tutor prior to when the assignment is due.
4) Do not start the exercises until to have fully read and fully understood the corresponding textbook sections. If there is something you do not fully understand, you must contact the instructor or course tutor prior to starting the assigned exercises.


[100 pts.] Chapter 20B
Read Section 20.5 of the textbook.

Do the following exercises in DrRacket (show all Design Recipe v2 steps whenever you Design a Function):
  • Exercise 20.5.2: Develop a function named swap-x-y which takes in a posn and returns a new posn with the coordinates swapped: the x coordinate of the output should be the y coordinate of the input, and vice versa.

  • Exercise 20.5.3: Develop a function named scale-posn which takes in a number and a posn, and returns a posn formed by multiplying the number by each of the coordinates of the input posn. For example, (scale-posn 3 (make-posn 2 5)) "should be" (make-posn 6 15).

  • Exercise 20.5.7: Develop a function named choose-posn that takes in a string and two posns. The string should be either "first" or "second". The choose-posn function should return either the first or the second of its two posns, as directed by the string. (Hint: You probably want to use a conditional expression as the function body for this function.)




  • GRADING Contract Purpose Data Analysis Examples Skeleton Inventory Added Details Definition
    20.5.2 /2 /1 N/A /3 /1 /2 /3 /18
    20.5.3 /2 /1 N/A /3 /1 /2 /3 /18
    20.5.7 /2 /1 /6 /3 /1 /2 /5 /20



    Last Modified: 12/1/14