[racket] HTDP 5.1.5

From: Stephen Chang (stchang216 at gmail.com)
Date: Mon Jan 31 12:27:36 EST 2011

Nice! Also, it's been pointed out that I made a typo in my previous
email. I meant symbols where I said strings, as you figured out.



On Mon, Jan 31, 2011 at 12:20 PM, Jeremy Duenas <jduenas23 at gmail.com> wrote:
> Thank you so much. I was able to figure it out. I don't know why I didn't
> think of utilizing the symbol=?
> After re-reading the error and not over thinking it I was able to see what I
> needed to do
> Jeremy D. Duenas
> 714.864.9686
>
>
>
> On Mon, Jan 31, 2011 at 8: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.