chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] case vs. eq? - just curious ....


From: Jim Ursetto
Subject: Re: [Chicken-users] case vs. eq? - just curious ....
Date: Fri, 2 Mar 2012 18:04:10 -0600

eqv?, to be exact.  Your case statement works fine for me, with for example (comp->text '=).  (eq? comp =) compares against the value of the procedure =, whereas the case compares against the symbol =.  So you are doing two different comparisons.

You can use ,x (case ...) at the REPL to see what the case expands to.

Fake edit: Kon said this more succinctly than I did.
Jim

On Mar 2, 2012, at 5:52 PM, Matt Welland wrote:

I expected this to work:

(define (comp->text comp)
  (case comp
   ((=)    "=")
   ((>)    ">")
   ((<)    "<")
   ((>=)  ">=")
   ((<=)  "<=")
   (else "unk")))

But had to convert to a cond with (eq? comp =) etc...

I thought case was supposed to use eq? to do the compare?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]