The teachpack adds the following primitive operations, in addition to those of HW 1:
Define the function product, which takes a list of numbers and produces the result of multiplying all of the numbers together. The product of an empty list is 1, for the same reason that n0 is 1 for any n.
Use the standard definition of list of numbers:
; A list-of-num is either ; - empty ; - (cons num list-of-num)
Define the function inflate-by-4%, which takes a list of numbers representing prices and returns a list of the prices inflated by 4%.
Define the function inflate-by-rate, which takes a list of numbers representing prices and an inflation rate (eg. 0.04 for 4% inflation). The function should returns a list of the prices inflated by the given rate.
Define the function eat-apples, which takes a list of symbols and returns a list containing the example symbols, except that every instance of 'apple is removed. For example, if a list of 10 symbols is provided where 'apple appears twice, the result is a list of 8 symbols.
Define the function distances, which takes a list of posns and returns a list of numbers that represent the distance from each posn to the origin. (See also section 6.1 in the textbook, page 54.)
Define the function photo-negative, which takes an image and returns a "negative" of the image. To create a negative, flip each of the red, green, and blue intensities of the image's pixels. For example, pure blue (make-color 0 0 255) turns into pure yellow (make-color 255 255 0), while medium gray (make-color 128 128 128) changes imperceptibly to (make-color 127 127 127).
Hint: most of the work should be in a helper function that is possibly named negate-colors.
Define the function kind-of-blue?, which takes an image and returns true if the total blue intensity of pixels in the image is greater than the total red intensity, and also greater than the total green intensity.
Hint: write three helper functions to compute three different total intensities.
For example, is not blue, but is kind-of blue.
Define the function same-image?, which takes two images and determines whether they are exactly the same. Do not use image=?.
Last update: Tuesday, September 16th, 2003mflatt@cs.utah.edu |