22a. Recursion Quiz

You may use the Picturing Programs textbook and the blog to look up functions th at you do not know. Do not consult any other programs written by you or anyone else. (No old homework, Stack Overflow, etc.)

Use define/contract and have at least two check expects for each function.

  1. reciprocal-squares: number(start) number(end) -> number. Find the sum of 1/n^2 for every n between start and end (including both).

    start end sum
    1 1 1.0
    1 2 1.25
    1 3 1.36111…
  2. blank-vowels: string(word) -> string. Change every vowel (a,e,i,o,u) to an underscore (_). Example: (blank-vowels "elephant") => "_l_ph_nt".

Period 5,7 Only

  1. circle-circle: number(big-radius) number(little-radius) number(turn-angle) number(n) -> image. Produce n circles of size little-radius around the perimeter of a circle of size big-radius. In between each, have a central angle of turn-angle.

    (circle-circle 100 20 45 8)

    (circle-circle 120 15 30 6)

Period 1 Only

  1. hollow-diagonal: number(radius) number(n): Produce n circles of the given radius along a diagonal.

    (hollow-diagonal 20 5)