[racket] Case with strings: normal behavior?
case compares with eqv?
strings are only ever eqv? if they are eq?
It turns out that Racket guarantees that all literal strings in your
program are eq if they have the same letters, so in your program, the
three "a"s are all the same object.
When you append the empty string to the end, you get a new object, so
it isn't eqv with the other three.
On Mon, Nov 19, 2012 at 6:07 AM, Laurent <laurent.orseau at gmail.com> wrote:
> Hi,
>
> Is this a bug or a not quite intuitive normal behavior?
>> (define (foo s)
> (case s
> [("a") 'a]
> [else 'none]))
>> (foo "a")
> 'a
>> (foo (string-append "a" ""))
> 'none
>
> in 5.3.1.5--2012-11-08(5589bcb/a) [3m].
>
> Laurent
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93