# Class 16: More Recursion with Lists

Back to Recursion with Lists. On to Recursion with Natural Numbers.

Held Wednesday, September 25, 2002

Summary

Today we continue our exploration of recursion over lists through experimentation and reflection.

Due

Notes:

• Many of you sent me notes at 3 a.m. indicating that you weren't able to get the homework done because of unknown errors.
• I will not penalize you for the lateness on this assignment.
• This offer is only available to those who show up for class.
• I'll wander around during lab to see if I can fix your problems.
• For the future: I'd rather that you go to sleep before midnight than that you get my assignments in on time.
• And as today shows, those who need to work beyond midnight don't often finish their assignments anyway.
• To continue our "P" theme, I brought pudding and pastries as well as Pop-Tarts (and today I brought real Pop Tarts as opposed to other kinds of toaster pastries).
• The focus of today's class is the recursion lab.
• No, I do not yet have homework 2 graded.

Overview

## Recursively Defined Data

• You may not have gotten this idea from the readings, but we define more than procedures recursively: We also define some data recursively.
• Lists: A list is either
• the empty list (base case)
• the cons of a value and a list (recursive case)
• Natural numbers: A natural number is either
• the value 0 (base case)
• one plus a natural number
• ...
• As you may have noticed, you can use these recursive definitions to ground your recursive procedures.

## Some Reflection

• As I look at my outline from the last time I taught this class, I see that many people in the class had problems with the square each element in the list problem. You folks seem to have done much better. Congrats!
• Are there other problems you've encountered or observations you've made in the initial work on the lab?
• Did any of you glean interesting ideas from the second reading on recursion?

## History

Thursday, 29 August 2002 [Samuel A. Rebelsky]

Wednesday, 25 September 2002 [Samuel A. Rebelsky]

• Removed other sections not necessary this year.

Back to Recursion with Lists. On to Recursion with Natural Numbers.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Mon Dec 2 08:41:07 2002.
The source to the document was last modified on Wed Sep 25 08:40:25 2002.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2002F/Outlines/outline.16.html`.

You may wish to validate this document's HTML ; ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu