BH: suggests putting this lab after the Social Implications, so that it is the last thing in the course.
AC: Still thinks that this unit should start with this lab. Indeed, it should come much earlier in the program. Oh well\dots

Walking Down a List

It's a big simplification to say that adding "s" always forms the plural. If you did the optional project on Plurals and you like, you can use your work from the plural block you made in Unit 2.

Here's the plurals block from Lab 1. It takes a list of words as input, and reports a list of the plurals of those words. Although there is a way to build this block using map, bear with us: there is a good reason to investigate this recursive version.
plurals (words){if(empty?(words)){report(list{})}else{report(join(item(1) of (words) (s) in front of (plurals(all but first of(words))))}}

The big idea here is that you can divide a list into its first item and all the rest of the items, form the plural of the first one, and make a recursive call for the rest. The in front of block may look strange at first, with its asymmetrical inputs (one item, one list), but it puts the plural of the first word and the plurals of the rest of the words back together.

This pattern of code can be used to build many useful recursive reporters that have a simple base case and a simple recursive call.

Do the following exercises using recursion, not higher-order functions.

  1. Try modifying the code from plurals.
    Make a squares block that takes a list of numbers as input, and reports a list of the squares of the numbers.

    squares(list{7,8,1}) reporting {49,64,1}

  2. Make an exaggerate block that takes a sentence as input, and reports a sentence in which every number in the input is doubled, "good" is replaced by "great," "bad" is replaced by "terrible," "like" is replaced by "love," and "dislike" is replaced by "hate."

    exaggerate(I ate 6 really good potstickers), reporting I ate 12 really great potstickers

    To do this, use a "wrapper" function that transforms the sentence into a list of words and back again:

    exaggerate(sentence){report(list->sentence(exaggerate wordlist(sentence->list(sentence))))}

    What should the helper function do with the other words?

    You'll also want a helper function exaggerate word that works on a single word, looking for specific words and types to exaggerate.

AC suggestion: include both iterative and recursive solutions in this lab.