CSE 341 -- Programming LanguagesAutumn 2001 |
Department of Computer Science and Engineering, University of WashingtonSteve Tanimoto (instructor) |
Assignment 4Version 1.0 of November 2 (Subject to Change) |
A Taste of MLDue date and time: Thursday, November 8, 2001 (at the beginning of section).Turn in this assignment as a hardcopy printout. However, electronic copies of the ML files will also be required; additional turn-in instructions will be announced later. |
Instructions:
Display the online document "A Gentle Introduction to ML"
by Andrew Cumming. Read Lesson 1 and Lesson 2.
Group Work: This assignment
should be performed individually (not in groups).
Part A: Simple Exercises
Make up an expression that will evaluate to...
Part B: Larger Chunks
- repeatElts [3, 1, 4, 1, 5, 9];
val it = [3, 3, 1, 1, 4, 4, 1, 1, 5, 5, 9, 9] : int list
Do this in two ways. The first should be called repeatElts1
and should use an if expression
and should not use patterns. The second should be called
repeatElts2, should use patterns,
and should not use an if expression.
Write a function inorderConcat that takes a tnode and
returns a string that consists of all the strings from
the nodes concatenated together and separated by blanks.
Use "inorder" traversal, meaning that all left subtree
strings come before the root's string, and all right
subtree strings come after the root's string.
Demonstrate your implementation of inorderConcat
on a tree that represents an English sentence of at least 8 words
in length.