22a. Recursion Practice 4

Change penguin to penguins and mouse to mice in zoo-1, sum5, double-middle.

Classwork (20 min) and discussion (25 min).

  1. zoo-1: string -> string. Change every occurrence of “penguin” to “penguins” and change every occurrence of “mouse” to “mice”. Leave everything else alone.

      (check-expect (zoo-1 "mouse") "mice")
      (check-expect (zoo-1 "xmouse") "xmice")
      (check-expect (zoo-1 "mousex") "micex")
      (check-expect (zoo-1 "mouse moose") "mice moose")
      (check-expect (zoo-1 "mouse mouse") "mice mice")
      (check-expect (zoo-1 "penguin penguins") "penguins penguinss")
    

Review Homework

  1. sum5: number(n) -> number. Find the sum of the first n fifth powers, starting with 1.

     (check-expect (sum5 3) (+ (* 1 1 1 1 1) (* 2 2 2 2 2) (* 3 3 3 3 3)))
    
  2. double-middle: string -> string. Double every letter between j and q in the alphabet (inclusive).

     (check-expect (double-middle "jog snake") "jjoog snnakke")
    
Last modified August 18, 2023: 2022-2023 End State (7352e87)