Lab 1: Records, Datatypes, and Pattern Matching
Due: ∅
Welcome again! Datatypes and pattern matching are the champagne and caviar of ML programming. If you don't yet believe that, do this lab, and you will find your beliefs altered.
1 Files and Directories
Here is a datatype for a description of files and directories. It's recursive and shapely.
Note that base
and ext
(for
“extension”) are standard names for the parts of a filename
before and after the dot, respectively. Here is an example
file_or_dir
value.
Write the functions corresponding to the following val
specifications. Use pattern matching as liberally as possible but no
more liberally. In particular, use underscores and record elisions
(three dots) for values that need not be named. You should be able to
infer what the following functions should compute by their names,
types and comments.
The last function should evaluate on mm
(from above) to
the following:
2 Errata
Revision 0 (Jan 14)
- None so far!