RU beehive logo ITEC dept promo banner
ITEC 380
2009spring
ibarland

homeinfolecturesexamshwsarchive

displayDeprecationNoticeAsOf(2009,05,31+01, "http://www.radford.edu/itec380/")

hw03
processing lists

Turn in on WebCT. In addition, if you're local, bring a hardcopy to class.

  1. (3pts) Give a data definition for a list-of-fire, and three examples.
    (Yes, the definition for list-of-fire is very close to our definition for list-of-symbol. It's a union type: two cases connected by "OR".)
  2. (5pts) Write the function grow-fires : (list-of fire) → (list-of fire). Include three test cases (written before you write the code), and code. (Be sure to use your function grow-fire from the previous homework; points taken off for repeating code!)
  3. (5pts) Write the function draw-fires : (list-of fire) scene → scene.
    (No test cases required, since it's hard to manufacture the result-images before you write your code.)
  4. (5pts) Write the function move-droplets, which deals with a list of droplets. Include test cases.
  5. (5pts) Write the function draw-droplets, which deals with a list of droplets. (No test cases required, since it's hard to manufacture the result-images before you write your code.)
  6. (5pts) Write the function fire-near-droplet? : fire droplet → boolean, which returns true if the given fire is close to the given droplet. (I'll let you determine how to calculate “close to”; you may find it easier to use the Manhattan distance than the standard Euclidean distance.)
  7. (5pts) Write the function fire-near-droplets? : fire (list-of droplet) → boolean, which returns true if the given fire is close to any of droplets in the given list. (Call your previous method, rather than repeating code!)
  8. (9pts) Chapter 1, Review Questions1
    1. #6
    2. #9
    3. #10
    4. #11
    5. #14
    6. #15
  9. (3pts) Chapter 1, Problem Set 18. “Our criteria” might include: readability vs writability; various costs; orthogonality vs. feature mulitplicity.
  10. (2pts)

    Which languages might be involved in setting up an on-line order system, for a store?
    (Feel free to chat with people who have taken Software Engineering.)

  11. (6 pts) Chapter 1 gives six costs associated with a programming language. Which single cost do you think is most important for…
    1. code controlling the space shuttle launch
    2. code for a payroll program to be used by a Coca-Cola International.
    3. code for a scientific simulation of proteins in a cell, to help develop new drugs.
    4. code to compute what percentage of RU students have more than one picture on their RU home web page. (Suppose that a friend is writing a report for a Media Studies project, and wants to include this statistic.)
    5. Code for maintaining all aspects of a course gradebook (entering and editing information, adding new features on demand like “replace-lowest-hw-with-exam-percentage”, generating web-views for instructor and students, adding new features to the web-views as requested, etc.).
    (Just give the name of the category, e.g. “compiling programs”.)

    Which of the five example programs above is most “typical” do you think, of the sort of programs most programmers tend to work on?

  12. (0pts) Read over Chpt 15 in the book (Functional Programming and scheme/Lisp).
  13. (5pts) Write subst:
    ; subst: atom atom (list-of atom)  → (list-of atom))
    ; 
    (define (subst old new data) 
      ...)
    
        
    (check-expect (subst 'apple 'zinger (list 'apple 'banana))
    (list 'zinger 'banana))
    (check-expect (subst 'apple 'zinger (list 'cherry 'banana))
    (list 'cherry 'banana))
    (check-expect (subst 'apple 'zinger (list 'apple 'banana 'apple 'kiwi 'apple))
    (list 'zinger 'banana 'zinger 'kiwi 'zinger))
        
    ;; PROVIDE AT LEAST TWO ADDITIONAL TEST CASES (which can be simpler than the above)
       
    
    ;; Note: 'list' vs 'cons':
    ;;    (list 'a 'b 'c)
    ;; returns
    ;;    (cons 'a (cons 'b (cons 'c empty))).
    ;; These two functions are related *but different*;
    ;; `list` tends to be useful for test-cases, while `cons` is usually what
    ;; you want inside your code.
      
    For this exercise, use only functions mentioned in the book and notes (updating to the book's old-school dialect). That is, don't use a built-in library function which does all the work for you.

1 Short correct answers get more credit than long correct answers; use a single word when possible.      

homeinfolecturesexamshwsarchive

displayDeprecationNoticeAsOf(2009,05,31+01, "http://www.radford.edu/itec380/")
©2009, Ian Barland, Radford University
Last modified 2009.Feb.14 (Sat)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme