(load "cpsD.ss") ;;; No changes below this line for the remaining algorithm. ;;; -------------------------------------------------------- ;;; CLAM guarantess that (CLAM (id) (APk x id)) translates to x ;;; provided that x is a symbol and unequal to id. (eta rule). ;;; This version of CLAM transforms occurrences of continuations like this: ;;; (CLAM (v^) (let ((a v^)) body)) ==> (CLAM (a) body). We know ;;; that v^ only appears once, since this is a continuation. This is ;;; an occurrence of a call-by-value eta reduction, since the ;;; expression can also be read as: ;;; (lambda (v^) ((lambda (a) body) v^)). ;;; This works because we know that v^ does not appear in body and ;;; (lambda (a) body) is a value. (define CLAM (lambda (E) (let ((formal (gen-sym "v"))) (let ((body (E formal))) (match body [(let ((,x ,y)) ,let-body) ;;; This is an eta reduction. (guard (eq? y formal)) `(CLAM (,x) ,let-body)] [(APk ,e ,x) (guard (eqv? x formal)) e] [,other `(CLAM (,formal) ,body)]))))) (load "cps-tester.ss") (define header "****************************** E *********************") (newline) (test-all header) (define resultsE test-results)