Copyright
Brief Table of Contents
Table of Contents
Foreword
Preface
Acknowledgments
About this Book
1. Introduction to functional programming
Chapter 1. What is functional programming?
1.1. The benefits of FP: a simple example
1.1.1. A program with side effects
1.1.2. A functional solution: removing the side effects
1.2. Exactly what is a (pure) function?
1.3. Referential transparency, purity, and the substitution model
1.4. Summary
Chapter 2. Getting started with functional programming in Scala
2.1. Introducing Scala the language: an example
2.2. Running our program
2.3. Modules, objects, and namespaces
2.4. Higher-order functions: passing functions to functions
2.4.1. A short detour: writing loops functionally
2.4.2. Writing our first higher-order function
2.5. Polymorphic functions: abstracting over types
2.5.1. An example of a polymorphic function
2.5.2. Calling HOFs with anonymous functions
2.6. Following types to implementations
2.7. Summary
Chapter 3. Functional data structures
3.1. Defining functional data structures
3.2. Pattern matching
3.3. Data sharing in functional data structures
3.3.1. The efficiency of data sharing
3.3.2. Improving type inference for higher-order functions
3.4. Recursion over lists and generalizing to higher-order functions
3.4.1. More functions for working with lists
3.4.2. Loss of efficiency when assembling list functions from simpler components
3.5. Trees
3.6. Summary
Chapter 4. Handling errors without exceptions
4.1. The good and bad aspects of exceptions