The language for this homework is:
#lang plait |
Begin by downloading the template file to serve as the basis of your work. Compared to the interpreter we studied in class, this one uses a slightly different surface syntax, closer to that of Racket. In particular the parameters of a lam form are enclosed in an extra set of parens, so e.g. the identity function is written {lam {x} x}.
(module+ test ;; test no arguments (test (run `{let1 {g {lam {} 42}} {g}}) 42) ;; test multiple arguments, lexical scope (test (run `{let1 {z 3} {let1 {f {lam {x y} {/ {- x y} z}}} {let1 {z 2} {f 15 12}}}}) 1) ;; higher order function (test (run `{let1 {identity {lam {x} x}} {let1 {plus {lam {x y} {+ x y}}} {{identity plus} 123 1}}}) 124) ;; higher order function with multiple arguments (test (run `{let1 {apply {lam {f x y} {f x y}}} {let1 {plus {lam {x y} {+ x y}}} {apply plus 123 1}}}) 124) ) |
(module+ test (test (duplicate-symbol? '()) #f) (test (duplicate-symbol? '(a b c)) #f) (test (duplicate-symbol? '(a b c d b e)) #t)) |
(test/exn (run `{lam {x y x} 42}) "duplicate") |