| |
| |
Preface | |
| |
| |
| |
Getting started | |
| |
| |
| |
Values, types, identifiers and declarations | |
| |
| |
| |
Simple function declarations | |
| |
| |
| |
Comments | |
| |
| |
| |
Recursion | |
| |
| |
| |
The power function | |
| |
| |
| |
About types and type checking | |
| |
| |
| |
Bindings and environments | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Basic values and operators | |
| |
| |
| |
Integers and reals | |
| |
| |
| |
Expressions, precedence, association | |
| |
| |
| |
Euclid's algorithm | |
| |
| |
| |
Evaluations with environments | |
| |
| |
| |
Characters and strings | |
| |
| |
| |
Truth values | |
| |
| |
| |
The if-then-else expression | |
| |
| |
| |
Overloaded operators | |
| |
| |
| |
Type inference | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Tuples and records | |
| |
| |
| |
Tuples | |
| |
| |
| |
Tuple patterns | |
| |
| |
| |
Infix functions on pairs | |
| |
| |
| |
Records | |
| |
| |
| |
Record patterns | |
| |
| |
| |
Type declarations | |
| |
| |
| |
Locally declared identifiers | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Problem solving I | |
| |
| |
| |
Problem statement: rational numbers | |
| |
| |
| |
Solution 1 | |
| |
| |
| |
Solution 2 | |
| |
| |
| |
Comparing the solutions | |
| |
| |
| |
A solution using records | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Lists | |
| |
| |
| |
Building lists | |
| |
| |
| |
The 'cons' operator | |
| |
| |
| |
List patterns | |
| |
| |
| |
Append and reverse; polymorphic types | |
| |
| |
| |
Polymorphic values | |
| |
| |
| |
A library of list functions | |
| |
| |
| |
Membership; equality types | |
| |
| |
| |
Type inference | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Problem solving II | |
| |
| |
| |
Problem analysis: cash register | |
| |
| |
| |
Programming | |
| |
| |
| |
Test | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Tagged values and partial functions | |
| |
| |
| |
Datatype declarations | |
| |
| |
| |
The case-expression | |
| |
| |
| |
Enumeration types | |
| |
| |
| |
The order type | |
| |
| |
| |
Partial functions: the option datatype | |
| |
| |
| |
Exception handling | |
| |
| |
| |
The Eight Queens problem | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Finite trees | |
| |
| |
| |
Chinese boxes | |
| |
| |
| |
Symbolic differentiation | |
| |
| |
| |
Trees of ancestors; traversal of a tree | |
| |
| |
| |
Mutual recursion | |
| |
| |
| |
Parameterized datatypes | |
| |
| |
| |
Electrical circuits | |
| |
| |
| |
Abstract types | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Higher-order functions | |
| |
| |
| |
Expressions denoting functions | |
| |
| |
| |
Value declarations of recursive functions | |
| |
| |
| |
The map function | |
| |
| |
| |
Declaring higher order functions | |
| |
| |
| |
Higher-order list functions | |
| |
| |
| |
Functional composition | |
| |
| |
| |
Tree recursion | |
| |
| |
| |
Type inference for higher-order functions | |
| |
| |
| |
Closures | |
| |
| |
| |
Static binding | |
| |
| |
| |
Lazy evaluation | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Finite sets | |
| |
| |
| |
A representation of sets | |
| |
| |
| |
Operations on sets | |
| |
| |
| |
An abstype for sets | |
| |
| |
| |
Other representations of sets | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Modules | |
| |
| |
| |
Structures | |
| |
| |
| |
Specifications and signatures | |
| |
| |
| |
Signatures and structures | |
| |
| |
| |
Further facilities | |
| |
| |
| |
Fixity of identifiers | |
| |
| |
| |
Functors | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Tables | |
| |
| |
| |
The table concept | |
| |
| |
| |
A representation of tables | |
| |
| |
| |
Operations on tables | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Problem solving III | |
| |
| |
| |
Problem analysis | |
| |
| |
| |
A sample run | |
| |
| |
| |
Programming | |
| |
| |
| |
Test | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Input/output in SML | |
| |
| |
| |
Input streams | |
| |
| |
| |
Output streams | |
| |
| |
| |
Simple input and output | |
| |
| |
| |
Use of conversions | |
| |
| |
| |
Sequential composition | |
| |
| |
| |
Input/output of composite data | |
| |
| |
| |
Input with prompt and validation | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Interactive programs | |
| |
| |
| |
A quiz program | |
| |
| |
| |
Actions | |
| |
| |
| |
Action schemas | |
| |
| |
| |
Functions for action schemas | |
| |
| |
| |
Dialogue automaton | |
| |
| |
| |
Dialogue program | |
| |
| |
| |
Action refinement | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Problem solving IV | |
| |
| |
| |
Problem analysis | |
| |
| |
| |
Programming | |
| |
| |
| |
Test | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Iteration | |
| |
| |
| |
Resource measures | |
| |
| |
| |
Two problems | |
| |
| |
| |
Solutions: accumulating parameters | |
| |
| |
| |
Iteration | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Imperative programming | |
| |
| |
| |
The store | |
| |
| |
| |
Operations on the SML store | |
| |
| |
| |
References and polymorphism | |
| |
| |
| |
Arrays | |
| |
| |
| |
The while loop | |
| |
| |
| |
Imperative data structures | |
| |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
Appendices | |
| |
| |
| |
SML systems | |
| |
| |
| |
Overview of Standard ML | |
| |
| |
| |
Lexical conventions | |
| |
| |
| |
Syntax | |
| |
| |
| |
Value, environment and store | |
| |
| |
| |
Types | |
| |
| |
| |
Semantics | |
| |
| |
| |
Overview of the SML module system | |
| |
| |
| |
Lexical conventions | |
| |
| |
| |
Syntax | |
| |
| |
| |
Interfaces and environments | |
| |
| |
| |
Semantics | |
| |
| |
| |
Selected parts of the SML basis library | |
| |
| |
| |
General | |
| |
| |
| |
Numbers | |
| |
| |
| |
Characters and strings | |
| |
| |
| |
Lists | |
| |
| |
| |
Vectors | |
| |
| |
| |
Arrays | |
| |
| |
| |
Timers and time | |
| |
| |
| |
Date | |
| |
| |
| |
Conversions | |
| |
| |
| |
Text input | |
| |
| |
| |
Text output | |
| |
| |
| |
Modules of sets and tables | |
| |
| |
| |
Sets | |
| |
| |
| |
Tables | |
| |
| |
| |
Signatures | |
| |
| |
| |
Structures | |
| |
| |
| |
The ASCII alphabet | |
| |
| |
| |
Further reading | |
| |
| |
Index | |