3 Getting Started
3.1 Motivating Example: Flags
3.2 Numbers
3.3 Expressions
3.4 Terminology
3.5 Strings
3.6 Images
3.6.1 Combining Images
3.6.2 Making a Flag
3.7 Stepping Back: Types, Errors, and Documentation
3.7.1 Types and Contracts
3.7.2 Format and Notation Errors
3.7.3 Finding Other Functions: Documentation
4 Naming Values
4.1 The Definitions Pane
4.2 Naming Values
4.2.1 Names Versus Strings
4.2.2 Expressions versus Statements
4.3 The Program Directory
4.3.1 Understanding the Run Button
4.4 Using Names to Streamline Building Images
5 From Repeated Expressions to Functions
5.1 Example: Similar Flags
5.2 Defining Functions
5.2.1 How Functions Evaluate
5.2.2 Type Annotations
5.2.3 Documentation
5.3 Functions Practice: Moon Weight
5.4 Documenting Functions with Examples
5.5 Functions Practice: Cost of pens
5.6 Recap: Defining Functions
6 Conditionals and Booleans
6.1 Motivating Example: Shipping Costs
6.2 Conditionals: Computations with Decisions
6.3 Booleans
6.3.1 Other Boolean Operations
6.3.2 Combining Booleans
6.4 Asking Multiple Questions
6.5 Evaluating by Reducing Expressions
6.6 Composing Functions
6.6.1 How Function Compositions Evaluate
6.6.2 Function Composition and the Directory
6.7 Nested Conditionals
6.8 Recap: Booleans and Conditionals
7 Introduction to Tabular Data
7.1 Creating Tabular Data
7.2 Extracting Rows and Cell Values
7.3 Functions over Rows
7.4 Processing Rows
7.4.1 Finding Rows
7.4.2 Ordering Rows
7.4.3 Adding New Columns
7.4.4 Calculating New Column Values
7.5 Examples for Table-Producing Functions
8 Processing Tables
8.1 Cleaning Data Tables
8.1.1 Loading Data Tables
8.1.2 Dealing with Missing Entries
8.1.3 Normalizing Data
8.1.4 Normalization, Systematically
8.1.4.1 Using Programs to Detect Data Errors
8.2 Task Plans
8.3 Preparing Data Tables
8.3.1 Creating bins
8.3.2 Splitting Columns
8.4 Managing and Naming Data Tables
8.5 Visualizations and Plots
8.6 Summary: Managing a Data Analysis
9 From Tables to Lists
9.1 Basic Statistical Questions
9.2 Extracting a Column from a Table
9.3 Understanding Lists
9.3.1 Lists as Anonymous Data
9.3.2 Creating Literal Lists
9.4 Operating on Lists
9.4.1 Built-In Operations on Lists of Numbers
9.4.2 Built-In Operations on Lists in General
9.4.3 An Aside on Naming Conventions
9.4.4 Getting Elements By Position
9.4.5 Transforming Lists
9.4.6 Recap: Summary of List Operations
9.5 Lambda: Anonymous Functions
9.6 Combining Lists and Tables
10 Processing Lists
10.1 Making Lists and Taking Them Apart
10.2 Some Example Exercises
10.3 Structural Problems with Scalar Answers
10.3.1 my-len: Examples
my-len
10.3.2 my-sum: Examples
my-sum
10.3.3 From Examples to Code
10.4 Structural Problems that Transform Lists
10.4.1 my-doubles: Examples and Code
my-doubles
10.4.2 my-str-len: Examples and Code
my-str-len
10.5 Structural Problems that Select from Lists
10.5.1 my-pos-nums: Examples and Code
my-pos-nums
10.5.2 my-alternating: Examples and Code
my-alternating
10.6 Structural Problems Over Relaxed Domains
10.6.1 my-max: Examples
my-max
10.6.2 my-max: From Examples to Code
10.7 More Structural Problems with Scalar Answers
10.7.1 my-avg: Examples
my-avg
10.8 Structural Problems with Accumulators
10.8.1 my-running-sum: First Attempt
my-running-sum
10.8.2 my-running-sum: Examples and Code
10.8.3 my-alternating: Examples and Code
10.9 Dealing with Multiple Answers
10.9.1 uniq: Problem Setup
uniq
10.9.2 uniq: Examples
10.9.3 uniq: Code
10.9.4 uniq: Reducing Computation
10.9.5 uniq: Example and Code Variations
10.9.6 uniq: Why Produce a List?
10.10 Monomorphic Lists and Polymorphic Types
11 Introduction to Structured Data
11.1 Understanding the Kinds of Compound Data
11.1.1 A First Peek at Structured Data
11.1.2 A First Peek at Conditional Data
11.2 Defining and Creating Structured and Conditional Data
11.2.1 Defining and Creating Structured Data
11.2.2 Annotations for Structured Data
11.2.3 Defining and Creating Conditional Data
11.3 Programming with Structured and Conditional Data
11.3.1 Extracting Fields from Structured Data
11.3.2 Telling Apart Variants of Conditional Data
11.3.3 Processing Fields of Variants
12 Collections of Structured Data
12.1 Lists as Collective Data
12.2 Sets as Collective Data
12.2.1 Picking Elements from Sets
12.2.2 Computing with Sets
12.3 Combining Structured and Collective Data
12.4 Data Design Problem: Representing Quizzes
13 Recursive Data
13.1 Functions to Process Recursive Data
13.2 A Template for Processing Recursive Data
14 Trees
14.1 Data Design Problem – Ancestry Data
14.1.1 Computing Genetic Parents from an Ancestry Table
14.1.2 Computing Grandparents from an Ancestry Table
14.1.3 Creating a Datatype for Ancestor Trees
14.2 Programs to Process Ancestor Trees
14.3 Summarizing How to Approach Tree Problems
14.4 Study Questions
15 Functions as Data
15.1 A Little Calculus
15.2 A Helpful Shorthand for Anonymous Functions
15.3 Streams From Functions
15.4 Combining Forces: Streams of Derivatives
16 Interactive Games as Reactive Systems
16.1 About Reactive Animations
16.2 Preliminaries
16.3 Version: Airplane Moving Across the Screen
16.3.1 Updating the World State
16.3.2 Displaying the World State
16.3.3 Observing Time (and Combining the Pieces)
16.4 Version: Wrapping Around
16.5 Version: Descending
16.5.1 Moving the Airplane
16.5.2 Drawing the Scene
16.5.3 Finishing Touches
16.6 Version: Responding to Keystrokes
16.7 Version: Landing
16.8 Version: A Fixed Balloon
16.9 Version: Keep Your Eye on the Tank
16.10 Version: The Balloon Moves, Too
16.11 Version: One, Two, ..., Ninety-Nine Luftballons!
17 Examples, Testing, and Program Checking
17.1 From Examples to Tests
17.2 More Refined Comparisons
17.3 When Tests Fail
17.4 Oracles for Testing