Lab 2: Making Lists

Students have touched on lists in Unit 1, but this lab is where we really dive into them. First, in the very simple shopping list app, students learn list creation and mutation. Then, in the quiz program, we introduce the very important idea of data abstraction, specifying a constructor and two selectors for the quiz item data type.

This layout/design makes me naturally want to read the brown and skip the white (especially the white at the top). --MF, 11/18/19
Data abstraction is a key idea in computer science. Many languages provide a special syntax for abstract data types, so you might say something like
class QuizItem {
   field question;
   field answer;
}
(That's not any particular language, just a stripped-down syntax to make the point.) But in Snap! we use procedures instead: the constructor quiz item, question: ( ) answer: ( ) to define the type, and selectors question from quiz item ( ) and answer from quiz item ( ) to retrieve the fields of the object. By using ordinary procedures to implement the abstract type, we show that there's no magic involved.

But what we don't do in this lab is to introduce the higher-order functions that will be our main tools for list processing later in the course. We hint at them in the third page by using for each item, which is a higher-order procedure but not a function, and therefore doesn't require the gray ring notation that will be introduced in the next lab.

Pacing

The 3 lab pages could be split across 2–4 days (75–150 minutes). Expected times to complete follow:

Lab Pages

Solutions

Correlation with 2020 AP CS Principles Framework 

Computational Thinking Practices: Skills

Learning Objectives:

Essential Knowledge: