[racket] Shurely Shome Mishtake

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sat Sep 4 16:35:50 EDT 2010

wooks . wrote at 09/04/2010 04:22 PM:
> (case "8"
>   (("8" "9" "10") 'hello)
>   (else 'goodbye)) -> goodbye

Unfortunately, you can't use "case" on strings, for somewhat esoteric 
reasons:

http://docs.racket-lang.org/reference/case.html
http://docs.racket-lang.org/reference/eval-model.html#(part._model-eq)

The R5RS document gives some more explanation and examples of what can 
be compared with eq/eqv/equal:

http://docs.racket-lang.org/r5rs-std/r5rs-Z-H-9.html#%_sec_6.1

You might find that "cond" or a hashtable can be used instead.  Or maybe 
you don't actually need strings at this point in the code, and there is 
a better way to do it.

-- 
http://www.neilvandyke.org/


Posted on the users mailing list.