## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Book Description

A programming course should concentrate as much as possible on a program's logical structure and design rather than simply show how to write code. The Functional Approach to Programming achieves this aim because logical concepts are evident and programs are transparent so can be written quickly and cleanly. In this book the authors emphasise the notions of function and function application which relate programming to familiar concepts from mathematics and logic. They introduce functional programming via examples but also explain what programs compute and how to reason about them. They show how the ideas can be implemented in the Caml language, a dialect of the ML family, and give examples of how complex programs from a variety of areas (such as arithmetic, tree algorithms, graph algorithms, text parsing and geometry) can be developed in close agreement with their specifications. Many exercises and examples are included throughout the book; solutions are also available.

1. Cover
2. Title
4. Contents
5. Preface
6. Introduction
7. I: Basic Principles
1. 1 Expressions
1. 1.1 Expressions and Definitions
2. 1.2 Elementary Types
3. 1.3 Cartesian Product
4. 1.4 Functions
5. 1.5 Polymorphism
7. 1.7 Scope of Identifiers
8. 1.8 More about Function Types: Equivalent Function Spaces
9. 1.9 Examples: Expressive Power
10. 1.10 Summary
2. 2 Data Structures
1. 2.1 Record or Named Cartesian Products
2. 2.2 Sums with Constructors
3. 2.3 Lists
4. 2.4 Summary
3. 3 Semantics
1. 3.1 Evaluation
2. 3.2 Defining Strategies
3. 3.3 Program Semantics
4. 3.4 Proving the Correctness of Programs
5. 3.5 Typing Expressions
6. 3.6 Summary
4. 4 Imperative Aspects
1. 4.1 Exceptions
2. 4.2 Input and Output
3. 4.3 Character Streams
4. 4.4 Modifiable Data Structures
5. 4.5 Semantics of Destructive Operations
6. 4.6 Summary
8. II: Applications
1. 5 Formal Terms, Pattern Matching, Unification
1. 5.1 Trees
2. 5.2 Terms with Variables
3. 5.3 Application: Type Synthesis
4. 5.4 Summary
2. 6 Balanced Trees
1. 6.1 Binary Trees
2. 6.2 Tree Traversais and Morphisms
3. 6.3 Order and Pre-Order Relations
4. 6.4 Binary Search Trees
5. 6.5 Balanced Trees
6. 6.6 Dictionaries
7. 6.7 Ordered Sets
8. 6.8 Functional Queues
9. 6.9 Summary
3. 7 Graphs and Problem Solving
1. 7.1 Algorithms to Explore Graphs
2. 7.2 The Red Donkey
3. 7.3 The Game of Solitaire
4. 7.4 Summary
4. 8 Syntactic Analysis
1. 8.1 Regular Expressions
2. 8.2 Context-Free Grammar
3. 8.3 Recognizers
4. 8.4 Analysis = Recognition + Values
5. 8.5 Streams and Pattern Matching
6. 8.6 Compiling Regular Expressions
7. 8.7 Summary
5. 9 Geometry and Drawings
1. 9.1 Meet MLgraph
2. 9.2 Drawing Trees
3. 9.3 Tiling
4. 9.4 Tiling a Hyperbolic Plane
5. 9.5 Summary
6. 10 Exact Arithmetic
1. 10.1 Representing Integers by Lists
2. 10.2 Other Representations of Natural Numbers
3. 10.3 Signed Integers, Both Negative and Positive
4. 10.4 Rational Numbers
5. 10.5 An Application: Computing π
6. 10.6 Summary
9. III: Implementation
1. 11 Evaluation
2. 12 Compilation
1. 12.1 A Simplified Model of Computer Memory
2. 12.2 Implementation of Data Structures
3. 12.3 Producing Code
4. 12.4 Implementation
5. 12.5 Examples
6. 12.6 Summary