From: Alan D. <ado...@cs...> - 2004-07-19 15:54:07
|
On Mon, Jul 19, 2004 at 11:24:26AM -0400, Ken Anderson wrote: > Tim, i'd like to propose this as a new definition of eqv? > (define (atomicClass? c) > (or (eq? c Boolean.class) > (eq? c Byte.class) > (eq? c Short.class) > (eq? c Integer.class) > (eq? c Long.class) > (eq? c Float.class) > (eq? c Double.class) > (eq? c Symbol.class))) (and don't forget Character.class) > (define (eqv? x y) > (or (eqv? x y) > (let ((c (.getClass x))) > (and (atomicClass? c) > (eq? c (.getClass y)) > (.equals x y))))) I think there's a typo for 'eq?' on line 2. What about the #null value? This would (unfortunately) require extra cases because (.getClass #null) fails. > You're using case incorrectly. Your code expands into: > (let ((temp var (String. "foo"))) > (cond ((member temp var '(String. "foo")) #t) > (else #f))) Right. I'm relatively new to Scheme ;-) Thanks for your help! (Sorry if my comments above are pedantic.) I'll subscribe to the list. cheers alan |