Homework #3

Assigned: February 3
Due: February 10, 4:30pm


  1. (10 points) Consider the following description of a function mystery.

    The function mystery takes a non-empty list of numbers in which no number is greater than its own index (first element is at index 1), and returns a list of numbers of the same length. Each number in the argument is treated as a backward index starting from its own position to a point earlier in the list of numbers. The result at each position is found by counting backward from the current position according to the index.

    Examples:
    > (mystery '(1 1 1 3 4 2 1 1 9 2))
    (1 1 1 1 1 4 1 1 1 9)
    > (mystery '(1 2 3 4 5 6 7 8 9))
    (1 1 1 1 1 1 1 1 1)
    > (mystery '(1 2 3 1 2 3 4 1 8 2 10))
    (1 1 1 1 1 1 1 1 2 8 2)
    
    Define the mystery function. Full credit will only be awarded to solutions which completely follow the Eleventh, Twelfth, and Thirteenth Commandments.

  2. (10+10=20 points) [EOPL] Exercise 1.19 on p. 31.

  3. (5 points) [EOPL] Exercise 1.27 on p. 34.

  4. (20 points) [EOPL] Exercise 1.31 on p. 37.



Return Home