程序代写 #!/usr/bin/env scheme-srfi-7

#!/usr/bin/env scheme-srfi-7

(requires srfi-34 srfi-78)
(files “myfns.ss”)

Copyright By PowCoder代写 加微信 powcoder

(define myinterpreter-with-exception-handling
(lambda (progs)
(call-with-current-continuation
(lambda (k)
(with-exception-handler
(lambda (x)
(display x)
(k “Error”)
(newline))
(lambda () (myinterpreter progs)))))))

(define (main args)
(check-set-mode! ‘report-failed)
(display “Grading myfns.ss”)

(check (myinterpreter-with-exception-handling
‘(planProg 10))

(check (myinterpreter-with-exception-handling
‘(planProg (planAdd 1 2)))

(check (myinterpreter-with-exception-handling
‘(planProg (planMul 2 5)))

(check (myinterpreter-with-exception-handling
‘(planProg (planSub 0 10)))

(check (myinterpreter-with-exception-handling
‘(planProg (planIf 0 5 10)))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet x 10 (planAdd x x))))

(check (myinterpreter-with-exception-handling
‘(planProg (planAdd 10 (planLet x 5 (planMul x x)))))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet x (planSub 0 (planLet x 10 x)) (planAdd x (planLet x 1 (planAdd x x))))))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet x (planSub 0 (planAdd 10 11)) (planLet y x (planMul x y)))))

(check (myinterpreter-with-exception-handling
‘(planProg (planIf (planAdd 0 1) (planLet x 10 x) (planLet x 15 x))))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet a (planFunction b (planAdd b b)) (a 5))))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet a (planFunction b (planAdd b b)) (planLet a 1 (planMul a a)))))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet f (planFunction x (planAdd 10 x)) (f 5))))

(check (myinterpreter-with-exception-handling
‘(planProg (planLet f (planFunction x (planAdd 10 x)) (f (f 5)))))

(display “Result:”)
(check-report))))

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com