[racket] HTDP 5.1.5

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Mon Jan 31 11:58:34 EST 2011

> can someone explain what I did wrong and how to correct this.

The error message you are getting seems like it's explaining your
problem pretty clearly. I dont know if it's possible to explain it any
other way. Re-read chapter 5 to see how strings are compared for
equality if you are still confused.




On Mon, Jan 31, 2011 at 11:25 AM, Jeremy Duenas <jduenas23 at gmail.com> wrote:
> Ok so I wrote and compiled my code:
> [code]
> ;;check-color: symbol symbol symbol symbol -> symbol
> ;;consumes four colors. 1 player picks two colors, the 2nd player guesses
> the colors. check-color simulates the 1st players checking action. It
> consumes four colors. The 1st two arguments to check-color are "targets" and
> the latter two are "guesses". the function produces one of the four
> answers.
> ;;example: (master check-color) = 'Perfect
> ;;         (masster check-color) = 'OneColorCorrectPosition
> ;;         (master check-color) = 'OneColorOccurs
> ;;         (master cheeck-color) = NothingCorrect
> (define t1 'red)
> (define t2 'green)
> (define (check-color t1 t2 g1 g2)
>   (cond
>     [(and (= t1 g1)(= t2 g2)) 'Perfect]
>     [(or (= t1 g1)(= t2 g2)) 'OneColorOccurs]
>     [(or (or (= t1 g1)(= t1 g2))(or (= t2 g1)(= t2 g2))) 'OneColorOccurs]
>     [else 'NothingCorrect]))
> [/code]
> It compiles correctly, but then when I run it using the master.ss  teachpack
> as told (master check-color) and choose two colors, I get the error:
>  =: expects type <number> as 1st argument, given: 'green; other arguments
> were: 'red
> can someone explain what I did wrong and how to correct this.
>
> Jeremy D. Duenas
> 714.864.9686
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



Posted on the users mailing list.