;;;;;;;;;;;;;;;;;;; TEST CASES: L1 ;;;;;;;;;;;;;;;; ;;; 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.) `{["{mod 3 4}" 3 ,(make-mod 3 4)] ["{mod {plus 5 6} 3}" 2 ,(make-mod (make-sum 5 6) 3)] ["{mod #e8.1 3}" #e2.1] ["{mod 8 #e3.1}" #e1.8] ["{mod #e-8.1 3}" #e0.9] ["{mod -8 #e3.1}" #e1.3] ["{mod #e8.1 -3}" #e-0.9] ["{mod 8 #e-3.1}" #e-1.3] ["{mod #e-8.1 #e-3}" #e-2.1] ["{mod #e-8 #e-3.1}" #e-1.8] #| The "#e" prefix means that the number is an exact number, | not floating-point. While exact-numbers are the default | in scheme's student langauges, floating-point is the default | in the 'module' language, grrr! | A slick solution: have your parser convert numbers | numbers |# ["{mod 8 2}" 0] ["{mod -8 2}" 0] ["{mod 8 -2}" 0] ["{mod -8 -2}" 0] ["{mod 8 3}" 2] ["{mod -8 3}" 1] ["{mod 8 -3}" -1] ["{mod -8 -3}" -2] ["{ifNeg 0 1 2}" 2] ["{ifNeg -2 -3 -4}" -3] ["{ifNeg {mod 8 -2} 3 {plus 3 {times 4 5}}}" 23] ["{ifNeg {mod 9 -2} 3 {plus 3 {times 4 5}}}" 3] })