Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-beginner-reader.ss" "lang")((modname Scheme) (read-case-sensitive #t) (teachpacks ((lib "convert.ss" "teachpack" "htdp") (lib "guess.ss" "teachpack" "htdp") (lib "master.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "convert.ss" "teachpack" "htdp") (lib "guess.ss" "teachpack" "htdp") (lib "master.ss" "teachpack" "htdp")))))
4 ;; check-guess : symbol symbol symbol symbol -> symbol
5 ;; Given guess1 and guess2, which are symbols representing the color of squares 1
6 ;; and 2, respectively, the function lets you check if the guesses are the same
7 ;; as target1 and target2.
9 (define (check-guess guess1 guess2 target1 target2)
10 (cond
11 [(and
12 (symbol=? guess1 target1)
13 (symbol=? guess2 target2))
14 'Perfect]
15 [(or
16 (symbol=? guess1 target1)
17 (symbol=? guess2 target2))
18 'OneColorAtCorrectPosition]
19 [(or
20 (symbol=? guess1 target2)
21 (symbol=? guess2 target1))
22 'OneColorOccurs]
23 [else 'NothingCorrect]))