#lang plai (require "wae.rkt") (define named-expr (add (num 3) (id 'x))) (test named-expr (parse '{+ 3 x})) (define with-ex1 (with 'y named-expr (sub (id 'y) (num 7)))) (test with-ex1 (parse '{with {y {+ 3 x}} {- y 7}})) (test (subst with-ex1 'x 3) (parse '{with {y {+ 3 3}} {- y 7}})) (define with-ex2 (with 'y named-expr (sub (id 'y) (id 'x)))) (test with-ex2 (parse '{with {y {+ 3 x}} {- y x}})) (test (subst with-ex2 'x 3) (parse '{with {y {+ 3 3}} {- y 3}})) (define sub-ex (add (num 3) (num 3))) (test (subst with-ex2 'y 3) with-ex2) (test (subst with-ex2 'y sub-ex) with-ex2) ;;