CS 360Lab 2

Name:
Lab 2 tasks(#1 in Scheme, #s 2-4 in ML, all on tux)

Access Lab 2 code you tested on tux in the preparation for Lab 2. Download and copy to tux the Scheme code BST.scmfrom
Part 1 (4 points)
(i) In Scheme, load the file delayedmap.scm.

What will the Scheme interpreter print when asked to evaluate the following expressions in the given order?

(take 5 L)

(take 7 L)

Explain why in the second call to the take function, the numbers 1-5 are not printed out.

(ii) In Scheme, load the file BST.scm.
It contains functions member and insert. Use function insert to construct a BST of height 2 consisting of numbers 1-7. Verify that all numbers 1-7 are in the BST using function member. How can you verify that the height of the tree you constructed is 2?

Show the results to the TA: ______(initials)
You may open another session on tux(keeping your current tux session active and available for reviewing) and proceed with the further work on Lab 2if the TA is currently not available.

Part 2 (3 points)
(i) In ML, load the file length.ml

Run tests of the len function.

Provide specifications for the len function.

(ii) In ML, load the file maxmin.ml

Run tests of the maxmin function.

Provide specifications for the maxmin function.

(iii) In ML, load the file msort.ml

Run tests of the msort function.
Provide specifications for the msort function.

Show the results to the TA: ______(initials)
You may open another session on tux (keeping your current tux session active and available for reviewing) and proceed with the further work on Lab 2 if the TA is currently not available.
Part 3 (3 points)
Implement in ML the following functions. Run several tests on each of them..
(i) A recursive implementation of
(ii) A recursive implementation of
(iii) Apply composition formulas via o andvia the codefrom the last line of the document
in order to construct .Verify that these two approaches give the same outcome.
Show the results to the TA: ______(initials)
You may open another session on tux (keeping your current tux session active and available for reviewing) and proceed with the further work on Lab 2 if the TA is currently not available.

Part 4 (extra credit, 4 points)
Implement in ML functions member and insert of Part 1 (ii). Run the same tests on them as in Part 1 (ii).

Show the results to the TA: ______(initials)