For instance, here's the SML code for it:
``` datatype exp =
Num of int
| Plus of exp * exp
| Minus of exp * exp
| Times of exp * exp
| Div of exp * exp
```Implement the function `eval : exp -> int`, which evaluates the expression as best as it can. Assume no division by zero.
Extra credit: Can you implement `eval' : exp -> int option`, that returns `SOME n` if the expression evaluates, and `NONE` if it divides by zero?
It looks like their current workflow keeps exams and homeworks off the internet effectively, but there's a 6-year-old codebase at https://github.com/zhengguan/15150-1 with 10-year-old homeworks and such.
A λ-calculus interpreter can be used as an intermediate level exercise. It is in particularly valuable in the context of solidifying one's understanding of functional programming.
You can also use "standard" textbooks, such as the SICP [0], and perform the exercises using the language of your choice, instead of Scheme/LISP.
[0]: https://mitp-content-server.mit.edu/books/content/sectbyfn/b...