;;;;;;;;;;;;;;;;;;; TEST CASES: L3 ;;;;;;;;;;;;;;;; ;;; The following is used by 'hw06-test-helpers.ss': (define tests ; Each entry in the list is either ; [str val] (where val is the result of interpreting the string str), or ; [str val expr] (as above, but expr is the internal (struct) representation. ; (You might need to adjust that third field, if you use a different ; internal representation than my solution.) `{["{fun x 5}" ,(make-fun 'x 5)] ["{fun x x}" ,(make-fun 'x 'x)] ["{fun x {plus x 1}}" ,(make-fun 'x (make-sum 'x 1))] ["{fun x {ifNeg x {times -1 x} x}}" ,(make-fun 'x (make-ifNeg 'x (make-prod -1 'x) 'x))] ["{fun x y}" ,(make-fun 'x 'y)] ["{fun x {fun y {plus x y}}}" ,(make-fun 'x (make-fun 'y (make-sum 'x 'y)))] ["{{fun x 5} 3}" 5] ["{{fun x x} 3}" 3] ["{{fun x {plus x 1}} 3}" 4] ["{{fun x {fun y {plus x y}}} 3}" ,(make-fun 'y (make-sum 3 'y)) ] ["{{fun x {ifNeg x {times -1 x} x}} -5}" 5] ["{{fun x {ifNeg x {times -1 x} x}} +5}" 5] ["{with abs {fun x {ifNeg x {times -1 x} x}} {abs -5}}" 5] ["{with abs {fun x {ifNeg x {times -1 x} x}} {abs +5}}" 5] ; Check that, when eval'ing a function-application, ; you evaluate the function being applied, since it might be ; a function-appliation-which-will-return-a-function: ["{{{fun x {fun y {plus x y}}} 3} 4}" 7] })