3 Basic Data
3.1 Getting Started
3.1.1 Motivating Example: Flags
3.1.2 Numbers
3.1.3 Expressions
3.1.4 Terminology
3.1.5 Strings
3.1.6 Images
3.1.6.1 Combining Images
3.1.6.2 Making a Flag
3.1.7 Stepping Back: Types, Errors, and Documentation
3.1.7.1 Types and Contracts
3.1.7.2 Format and Notation Errors
3.1.7.3 Finding Other Functions: Documentation
3.2 Naming Values
3.2.1 The Definitions Pane
3.2.2 Naming Values
3.2.2.1 Names Versus Strings
3.2.2.2 Expressions versus Statements
3.2.3 The Program Directory
3.2.3.1 Understanding the Run Button
3.2.4 Using Names to Streamline Building Images
3.3 From Repeated Expressions to Functions
3.3.1 Example: Similar Flags
3.3.2 Defining Functions
3.3.2.1 How Functions Evaluate
3.3.2.2 Type Annotations
3.3.2.3 Documentation
3.3.3 Functions Practice: Moon Weight
3.3.4 Documenting Functions with Examples
3.3.5 Functions Practice: Cost of pens
3.3.6 Recap: Defining Functions
3.4 Conditionals and Booleans
3.4.1 Motivating Example: Shipping Costs
3.4.2 Conditionals: Computations with Decisions
3.4.3 Booleans
3.4.3.1 Other Boolean Operations
3.4.3.2 Combining Booleans
3.4.4 Asking Multiple Questions
3.4.5 Evaluating by Reducing Expressions
3.4.6 Composing Functions
3.4.6.1 How Function Compositions Evaluate
3.4.6.2 Function Composition and the Directory
3.4.7 Nested Conditionals
3.4.8 Recap: Booleans and Conditionals
4 Tabular Data
4.1 Introduction to Tabular Data
4.1.1 Creating Tabular Data
4.1.2 Extracting Rows and Cell Values
4.1.3 Functions over Rows
4.1.4 Processing Rows
4.1.4.1 Finding Rows
4.1.4.2 Ordering Rows
4.1.4.3 Adding New Columns
4.1.4.4 Calculating New Column Values
4.1.5 Examples for Table-Producing Functions
4.2 Processing Tables
4.2.1 Cleaning Data Tables
4.2.1.1 Loading Data Tables
4.2.1.2 Dealing with Missing Entries
4.2.1.3 Normalizing Data
4.2.1.4 Normalization, Systematically
4.2.1.4.1 Using Programs to Detect Data Errors
4.2.2 Task Plans
4.2.3 Preparing Data Tables
4.2.3.1 Creating bins
4.2.3.2 Splitting Columns
4.2.4 Managing and Naming Data Tables
4.2.5 Visualizations and Plots
4.2.6 Summary: Managing a Data Analysis
5 Lists
5.1 From Tables to Lists
5.1.1 Basic Statistical Questions
5.1.2 Extracting a Column from a Table
5.1.3 Understanding Lists
5.1.3.1 Lists as Anonymous Data
5.1.3.2 Creating Literal Lists
5.1.4 Operating on Lists
5.1.4.1 Built-In Operations on Lists of Numbers
5.1.4.2 Built-In Operations on Lists in General
5.1.4.3 An Aside on Naming Conventions
5.1.4.4 Getting Elements By Position
5.1.4.5 Transforming Lists
5.1.4.6 Recap: Summary of List Operations
5.1.5 Lambda: Anonymous Functions
5.1.6 Combining Lists and Tables
5.2 Processing Lists
5.2.1 Making Lists and Taking Them Apart
5.2.2 Some Example Exercises
5.2.3 Structural Problems with Scalar Answers
5.2.3.1 my-len: Examples
my-len
5.2.3.2 my-sum: Examples
my-sum
5.2.3.3 From Examples to Code
5.2.4 Structural Problems that Transform Lists
5.2.4.1 my-doubles: Examples and Code
my-doubles
5.2.4.2 my-str-len: Examples and Code
my-str-len
5.2.5 Structural Problems that Select from Lists
5.2.5.1 my-pos-nums: Examples and Code
my-pos-nums
5.2.5.2 my-alternating: Examples and Code
my-alternating
5.2.6 Structural Problems Over Relaxed Domains
5.2.6.1 my-max: Examples
my-max
5.2.6.2 my-max: From Examples to Code
5.2.7 More Structural Problems with Scalar Answers
5.2.7.1 my-avg: Examples
my-avg
5.2.8 Structural Problems with Accumulators
5.2.8.1 my-running-sum: First Attempt
my-running-sum
5.2.8.2 my-running-sum: Examples and Code
5.2.8.3 my-alternating: Examples and Code
5.2.9 Dealing with Multiple Answers
5.2.9.1 uniq: Problem Setup
uniq
5.2.9.2 uniq: Examples
5.2.9.3 uniq: Code
5.2.9.4 uniq: Reducing Computation
5.2.9.5 uniq: Example and Code Variations
5.2.9.6 uniq: Why Produce a List?
5.2.10 Monomorphic Lists and Polymorphic Types
5.3 Recursive Data
5.3.1 Functions to Process Recursive Data
5.3.2 A Template for Processing Recursive Data
6 Structured Data
6.1 Introduction to Structured Data
6.1.1 Understanding the Kinds of Compound Data
6.1.1.1 A First Peek at Structured Data
6.1.1.2 A First Peek at Conditional Data
6.1.2 Defining and Creating Structured and Conditional Data
6.1.2.1 Defining and Creating Structured Data
6.1.2.2 Annotations for Structured Data
6.1.2.3 Defining and Creating Conditional Data
6.1.3 Programming with Structured and Conditional Data
6.1.3.1 Extracting Fields from Structured Data
6.1.3.2 Telling Apart Variants of Conditional Data
6.1.3.3 Processing Fields of Variants
6.2 Collections of Structured Data
6.2.1 Lists as Collective Data
6.2.2 Sets as Collective Data
6.2.2.1 Picking Elements from Sets
6.2.2.2 Computing with Sets
6.2.3 Combining Structured and Collective Data
6.2.4 Data Design Problem: Representing Quizzes
7 Trees
7.1 Trees
7.1.1 Data Design Problem – Ancestry Data
7.1.1.1 Computing Genetic Parents from an Ancestry Table
7.1.1.2 Computing Grandparents from an Ancestry Table
7.1.1.3 Creating a Datatype for Ancestor Trees
7.1.2 Programs to Process Ancestor Trees
7.1.3 Summarizing How to Approach Tree Problems
7.1.4 Study Questions
8 Foundations: Bonus Materials
8.1 Functions as Data
8.1.1 A Little Calculus
8.1.2 A Helpful Shorthand for Anonymous Functions
8.1.3 Streams From Functions
8.1.4 Combining Forces: Streams of Derivatives
8.2 Queues from Lists
8.2.1 Using a Wrapper Datatype
8.2.2 Combining Answers
8.2.3 Using a Picker
8.2.4 Using Tuples
8.2.5 A Picker Method
8.3 Examples, Testing, and Program Checking
8.3.1 From Examples to Tests
8.3.2 More Refined Comparisons
8.3.3 When Tests Fail
8.3.4 Oracles for Testing