# Class 24: Revisiting Lists

Back to Conditionals. On to Recursion Basics.

This outline is also available in PDF.

Held: Friday, March 5, 2010

Summary: We explore further details of Scheme's lists. Lists can be a key mechanism for structuring data. We also consider how lists can be used to represent drawings.

Related Pages:

Notes:

• Reading for Monday: Recursion Basics (Warning: the reading is complex; expect to bring questions).
• Are there questions on Assignment 6?
• Skip problems 5 & 6 on today's lab.
• It appears that we'll have lots of missing students today.
• EC for today's Peace Studies sessions (1p, 3pm, or 4:45 pm).

Overview:

• Lists, Revisited
• New List Operations
• Drawings as Values

## Lists, Revisited

• Original notion of lists:
• Collection of values
• Homogeneous: All the values in a list are the same type
• Used primarily with `map` and `for-each`
• Extending that notion
• Can also be heterogeneous: Values in the list may have multiple types
• Can examine individual elements with `car`, `cdr`, and `list-ref`.
• Can be extended (creating new lists) with `cons`.
• Why is the new view important?
• It will soon give us the opportunity to manipulate lists in new and interesting ways.

## Implementing Drawings

• We can (and do) use lists to implement drawings.
• The reading considers a simplified representation, in which the width and height of a drawing are the same.
• But the general process is the same
• Group the values in a list
• When we need to render or manipulate a drawing, use the list operations to extract parts.

Back to Conditionals. On to Recursion Basics.

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 Tue May 11 09:03:11 2010.
The source to the document was last modified on Thu Jan 21 13:05:13 2010.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2010S/Outlines/outline.24.html`.

You may wish to validate this document's HTML ; ;

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials copyright by John David Stone and Henry Walker and used by permission.) This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit `http://creativecommons.org/licenses/by-nc/2.5/` or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.