Definition 1.1.2 The set list-of-numbers is the smallest set of values satisfying the two properties:
- The empty list is a list-of-numbers, and
- If l is a list-of-numbers and n is a number, then the cons expression (n :: l) is a list-of-numbers
type Symbol = string
Or a tagged type:
type Symbol = Symbol of string
The latter will be more useful when defining other types of expressions, like the examples for the lambda-calculus. In this case there will be symbols, applications and abstractions, and not only a single variant.
With this in mind, it's easy to define a list-of-symbols type. At this point in the book, though, there's not much attention to representation of the data types, as the goal is to become familiar with recursive definitions. It uses the lisp pair notation, however, and lisp symbols, and these dependencies would be thus represented in F#. The same would hold for Standard ML or OCaml, of course.
No comments:
Post a Comment