The following interactions window transcript shows the results of defining and evaluating several expressions using the HW5 MUPL interpreter. These are similar to the demo in class on Wednesday, Feb. 13. Lines beginning with '>' are input typed in the interactions window.
> (eval-exp (int 17)) (int 17) > (eval-exp (var "x")) . . unbound variable during evaluation "x" > (mlet "x" (int 17) (var "x")) (mlet "x" (int 17) (var "x")) > (eval-exp (mlet "x" (int 17) (var "x"))) (int 17) > (define letexpr (mlet "x" (int 17) (add (var "x") (int 1)))) ; name mupl expr > letexpr (mlet "x" (int 17) (add (var "x") (int 1))) > (eval-exp letexpr) (int 18) > (fun "id" "x" (var "x")) (fun "id" "x" (var "x")) > (eval-exp (fun "id" "x" (var "x"))) (closure '() (fun "id" "x" (var "x"))) > (define muplid (fun null "x" (var "x"))) > muplid (fun '() "x" (var "x")) > (eval-exp muplid) (closure '() (fun '() "x" (var "x"))) > (eval-exp (call muplid (int 42))) (int 42) > (define mupl-addseq (fun "addseq" "n" (ifnz (var "n") (int 1) (int 0)))) > (eval-exp mupl-addseq) (closure '() (fun "addseq" "n" (ifnz (var "n") (int 1) (int 0)))) > (call mupl-addseq (int 0)) (call (fun "addseq" "n" (ifnz (var "n") (int 1) (int 0))) (int 0)) > (eval-exp (call mupl-addseq (int 0))) (int 0) > (eval-exp (call mupl-addseq (int 1))) (int 1) > (define mupl-addseq (fun "addseq" "n" (ifnz (var "n") (int 1) (call (var "addseq") (int 2))))) > (eval-exp (call mupl-addseq (int 1))) (int 1) > (eval-exp (call mupl-addseq (int 0))) (int 1) > (define mupl-sumseq (fun "sumseq" "n" (ifnz (var "n") (add (var "n") (call (var "sumseq") (add (var "n") (int -1)))) (int 0)))) > (eval-exp (call mupl-sumseq (int 0))) (int 0) > (eval-exp (call mupl-sumseq (int 1))) (int 1) > (eval-exp (call mupl-sumseq (int 2))) (int 3) > (eval-exp (call mupl-sumseq (int 3))) (int 6)