Project #6: μScheme in ML

Submit: Turn in your mlscheme.sml source file using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines.

Work is to be completed in teams of two. Be certain to include both teammates names in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline.

Include a comment block at the very top of each file that contains the following:

  (* COSC 3410 - Project 6 *)
  (* @author [your names] *)
  (* Instructor [your instructor] *)
  (* TA-BOT:MAILTO [your email addresses] *)

Q1 - cond

Textbook Chapter 5, section 5.8.2: Exercise #1 - Syntactic sugar for cond.

Examples:
> (define compare-numbers (n m)
     (cond
       [(< n m) 'less]
       [(= n m) 'equal]
       [(> n m) 'greater]
    ))
compare-numbers
> (compare-numbers 3 5)
less
> (compare-numbers 5 5)
equal
> (compare-numbers 6 5)
greater
> (cond)
Run-time error: Cond: all question results were false!

Q2 - Short-Circuit && and ||

Chapter 2.16.16, exercise 53. Port forward our previous assignment's short-circuit && and || syntactic sugar into the ML version of the μScheme interpreter.

Note that while a proper version of desugared || requires a fresh variable, we do not yet have that infrastructure available in the ML version of this interpreter. Make do with a hard-coded freshvar%1, and avoid testcases that use that specific variable name.


[back]

[Revised 2023 Oct 23 13:40 DWB]