An Introduction to Functional Programming, Lazy Evaluation, and Streams in Python
Portions of this textbook were adapted from the following (excellent) introductory textbook. If you are interested in using an open-source, online, interactive textbook in an introductory programming course, this book is highly recommend by the primary author (Todd Iverson).
This interactive book is a product of the Runestone Interactive Project at Luther College, led by Brad Miller and David Ranum. There have been many contributors to the project. Our thanks especially to the following:
- This book is based on the Original work by: Jeffrey Elkner, Allen B. Downey, and Chris Meyers
- Activecode based on Skulpt
- Codelens based on Online Python Tutor
- Many contributions from the CSLearning4U research group at Georgia Tech.
- ACM-SIGCSE for the special projects grant that funded our student Isaac Dontje Lindell for the summer of 2013.
- NSF
The Runestone Interactive tools are open source and we encourage you to contact us, or grab a copy from GitHub if you would like to use them to write your own resources.
Table of Contents¶
- 1. Introduction to Python
- 2. Expressions and Evaluation
- 3. Sequential Data Structures in Python
- 3.1. Collection Types - Strings, Lists and Tuples
- 3.2. Operations On Sequences
- 3.3. Accessing Sequence Data
- 3.4. Asking Boolean Questions about Sequences
- 3.5. Mutable and Immutable Sequences
- 3.6. References to Sequences
- 3.7. Sequence Methods and Working with Strings and Lists
- 3.8. Computational Complexity and Big O Notation.
- 3.9. Other Python Sequence Types
- 3.10. Exercises
- 4. Expression-Oriented Sequence Transformations
- 4.1. Transforming Sequences with Comprehensions
- 4.2. Working with Strings and Lists
- 4.3. Common Comprehension Patterns for a Single Sequence
- 4.4. Common Comprehension Patterns for Two Sequences
- 4.5. Common Comprehension Patterns for Tables
- 4.6. Levels of Abstraction
- 4.7. The Computational Complexity of a List Comprehension
- 4.8. Exercises
- 5. Associative Data Structures - Dictionaries and Sets
- 6. Reading Data from Files
- 7. Functional List Processing
- 7.1. More Details About Python Functions
- 7.2. Python Functional Parameters
- 7.3. Three General Tasks
- 7.4. What are Higher Order Functions?
- 7.5. Other Examples of Higher Order Functions
- 7.6. Common Patterns for Processing Sequences with Dictionaries
- 7.7. Lazy Iteration
- 7.8. Working with Large Files
- 7.9. Exercises
Labs¶
Appendices¶
Acknowledgements¶
The following links include information related to the ThinkCPY project, and open-source book from which a portion of this textbook was constructed.
- Copyright Notice
- Preface to the Interactive Edition
- Whats the deal with Logging in?
- How to Contribute
- Acknowledgements
- Foreword
- Preface to the Third Edition
- The Rhodes Local Edition (RLE)
- Preface to the First and Second Editions
- Contributor List
- GNU Free Documentation License
- ADDENDUM: How to use this License for your documents