-<script>
-/*jslint evil: true */
-
-/*members create, error, message, name, prototype, stringify, toSource,
- toString, write
-*/
-
-/*global JSON, make_parse, parse, source, tree */
-
-// Make a new object that inherits members from an existing object.
-
-if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- function F() {}
- F.prototype = o;
- return new F();
- };
-}
-
-// Transform a token object into an exception object and throw it.
-
-Object.prototype.error = function (message, t) {
- t = t || this;
- t.name = "SyntaxError";
- t.message = message;
- throw t;
-};
-
-
-(function () {
- var parse = make_parse();
-
- function go(source) {
- var string, tree, expr, eta;
- try {
- tree = parse(source);
- // string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
- expr = tree.handler();
- // string = JSON.stringify(expr, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
-// string = expr.to_string() + "\n\n~~>\n\n";
- string = '';
- eta = document.getElementById('ETA').checked;
- string = string + reduce(expr, eta, false).to_string();
- } catch (e) {
- string = JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
- 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
- }
- document.getElementById('OUTPUT').innerHTML = string
- .replace(/&/g, '&')
- .replace(/[<]/g, '<');
- }
-
- document.getElementById('PARSE').onclick = function (e) {
- go(document.getElementById('INPUT').value);
- };
-}());
-
-</script>
+
+Limitations of this scheme include the following: there is no easy way
+to label a constituent with a syntactic category (S or NP or VP,
+etc.), and there is no way to represent a tree in which a mother has a
+single daughter.
+
+When processing a tree, you can test for whether the tree contains
+only a numeral (in which case the tree is leaf node) by testing for
+whether the length of the list is less than or equal to 1. This will
+be your base case for your recursive functions that operate on these
+trees.
+
+1. Write a function that sums the number of leaves in a tree.
+
+Expected behavior:
+
+<pre>
+let t1 = (makeList 1 nil) in
+let t2 = (makeList 2 nil) in
+let t3 = (makeList 3 nil) in
+let t12 = (makeList t1 (makeList t2 nil)) in
+let t23 = (makeList t2 (makeList t3 nil)) in
+let ta = (makeList t1 t23) in
+let tb = (makeList t12 t3) in
+let tc = (makeList t1 (makeList t23 nil)) in
+
+sum-leaves t1 ~~> 1
+sum-leaves t2 ~~> 2
+sum-leaves t3 ~~> 3
+sum-leaves t12 ~~> 3
+sum-leaves t23 ~~> 5
+sum-leaves ta ~~> 6
+sum-leaves tb ~~> 6
+sum-leaves tc ~~> 6
+</pre>
+
+2. Write a function that counts the number of leaves.
+