On this page:
Minor Exercises
Major Exercises
6.10.0.2

15 Lab Practice with Hash Langs

Minor Exercises

This section collects the exercises from Matthew F. Building Languages.

Exercise 38. Racket’s define forms can appear in (let () ....) to make the definition local to the let form. Given that fact, define lambda without referring to the built-in lambda form. image

Exercise 39. Add a match clause (or several) to the new-lambda macro so that lambda shapes (trees) other than

(lambda (x:id) e:expr)

behave as before. Note If you know more than basic Racket but not the whole language, just get some shapes to work—not all of lambda. image

Exercise 40. Adjust "noisy-lambda.rkt" to make define create noisy functions, too, when it’s used in function-shorthand mode—like (define (f x) 11), as opposed to (define x 8) or (define f (lambda (x) 11)). image

Exercise 41. To avoid the possibility of divide-by-zero errors, adjust "noisy-racket.rkt" to not export /, modulo, or remainder. image

Exercise 42. To allow division without the possibility of divide-by-zero errors, adjust "noisy-racket.rkt" export variants of /, modulo, or remainder that return +inf.0 when the second argument is 0. image

Exercise 43. Racket’s #%app implements left-to-right evaluation of function-call arguments. Change "noise-racket.rkt" so that it implements right-to-left evaluation of arguments to a function call. You’ll need to use Racket’s #%app to implement your new #%app. image

Exercise 44. Make a language module (to be used after #lang s-exp) that is like racket but adjusts #%top-interaction to wrap time around each form to show how long it takes to evaluate. image

Exercise 45. Some users of #lang noisy may miss DOS-style comments using REM. Adjust the reader so that it detects and discards an REM result, discarding the rest of the line as well, and then tries reading again. Use syntax? to detect a non-EOF result from read-syntax, and use read-line to consume (the rest of) a line from an input stream. image

Major Exercises

Start with the QL implementation. You can pick any of the QL variants as a starting point, but one with at least type checking will be the most interesting, and the one with non-S-expression syntax should be within reach.

Exercise 46. Add an if form for use in guards or expressions to compute field values. image

Exercise 47. Add a text field type, where "gui.rkt" already provides text-widget. image