I'm getting the same error, but am not yet convinced I haven't done
anything wrong.
I've recently returned to this book after a 2 year break and don't
recall this one causing me any trouble.
I currently have
; a word is a structure
(define-struct word (w1 w2 w3))
;where 1 2 and 3 are symbols; 'a to 'z and '_
#|
(define (fun-for-word a-word)
... (word-1 a-word) ...
... (word-2 a-word) ...
... (word-3 a-word) ...)
|#
;draw-next-part symbol -> effect on canvas
;to consume a symbol representing a body part and draw the
corresponding part on the canvas
(define (draw-next-part part)
(cond
((symbol=? part 'left-leg)
(draw-solid-line (make-posn 100 300) (make-posn 180 380)))
((symbol=? part 'right-leg)
(draw-solid-line (make-posn 100 300) (make-posn 20 380)))
((symbol=? part 'left-arm)
(draw-solid-line (make-posn 100 150) (make-posn 180 230)))
((symbol=? part 'right-arm)
(draw-solid-line (make-posn 100 150) (make-posn 20 230)))
((symbol=? part 'body)
(draw-solid-line (make-posn 100 150) (make-posn 100 300)))
((symbol=? part 'head)
(and (and (and (and (and (draw-a-circle (make-circle (make-posn
100 100) 50 'red)) (draw-solid-line (make-posn 85 75) (make-posn 75
85))) (draw-solid-line (make-posn 75 75) (make-posn 85 85))) (draw-
solid-line (make-posn 125 75) (make-posn 115 85))) (draw-solid-line
(make-posn 125 85) (make-posn 115 75))) (draw-a-circle (make-circle
(make-posn 100 125) 10 'red))))
((symbol=? part 'noose)
(and (draw-solid-line (make-posn 1 10) (make-posn 85 10)) (draw-
solid-line (make-posn 85 10) (make-posn 85 50))))
(else 'noSuchPart)))
;reveal word word symbol -> word
;reveal consumes a chosen word, a status word and a guess letter and
updates the status word if the chosen word contains the guess letter
(1 letter symbol)
(define (reveal chosen status guess)
(make-word (match-word (word-w1 chosen) (word-w1 status) guess)
(match-word (word-w2 chosen) (word-w2 status) guess) (match-word (word-
w3 chosen) (word-w3 status) guess)))
;match-word symbol symbol symbol -> symbol
;match-word consumes a chosen letter, a status letter and a guess
letter. if the guess letter matches the chosen letter it outputs the
guess letter otherwise it outputs the status letter.
(define (match-word chosen status guess)
(cond
((symbol=? guess chosen) chosen)
(else status)))
The functions passed any tests I did though ,
(reveal (make-word 'c 'a 't) (make-word '_ '_ '_) 'c)
gives:
(make-word 'c '_ '_)
so I guess I'll call it done? The only thing that doesn't work is:
(hangman make-word reveal draw-next-part)
Which gives the error:
hangman: expected words to be structures with three fields, found 4
fields
Just hope I'm not missing anything.