[previous] [up] [next]     [contents]
Next: Syntax of define-struct Up: InformationData, and Structural Previous: Variable Definitions

Intermezzo 1: Structures

For this Intermezzo, change DrScheme's language level to Intermediate by selecting the Language|Configure Language... menu item. You may change it back to Beginner after the Intermezzo, since Part II does not rely on Intermediate. You may also choose to continue using Intermediate for Part II, which would allow you to use define-syntax to solve the exercises.

Preview to Intermezzo 2: A New Way to Name Lists

When you switch to the Intermediate language level, DrScheme uses a shorthand notation for naming lists. Instead of printing

(cons 1 (cons 2 (cons 3 empty)))

DrScheme prints
(list 1 2 3)

which is shorthard for a list containing the numbers 1, 2, and 3.

The list shorthand is explained further in the book's Intermezzo 2: List Abbrevisions. The shorthand does not make cons obsolete. On the contrary, cons is still more important than list because it is the only way to extend a list. While cons takes and item and a list to extend, list takes only the items of the list. Thus,

(cons 1 (list 2 3)) = (list 1 2 3)

but
(list 1 (list 2 3)) = (list 1 (list 2 3))

The former is a list containing three items. The latter is a list containing two items: the number 1 and another list.





PLT