For Programmers: Free Programming Magazines  


Home > Archive > Scheme > March 2007 > eq? eqv?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author eq? eqv?
math.idiot@gmail.com

2007-03-18, 7:10 pm

(display "------------------------")(display #\newline)
(display (eq? (* 2 2) (sqrt 16)))(display #\newline)
(display (eq? (cons 1 2) (cons (- 2 1) (+ 1 1))))(display #\newline)
(display (eqv? (* 2 2) (sqrt 16)))(display #\newline)
(display (eqv? (cons 1 2) (cons (- 2 1) (+ 1 1))))(display #\newline)
(define x (/ 5 7))
(define y (/ 5 7))
(display (eq? x y))(display #\newline)
(display (eqv? x y))(display #\newline)
(display (equal? 3 (/ 6 2)))(display #\newline)
(display (equal? 3 (/ 6 2.0)))(display #\newline)
(display (equal? '(1 2 3) '(1 2 3)))(display #\newline)

All versions are latest as of yesterday.
mzscheme:
#t #f #t #f #f #t #t #f #t
scheme48:
#f #f #f #f #f #t #t #f #t
guile:
#f #f #f #f #f #t #t #f #t
bigloo:
#f #f #f #f #f #t #t #f #t
gambit:
#t #f #t #f #f #t #t #f #t
larceny:
#f #f #f #f #f #t #t #f #t

Jens Axel Søgaard

2007-03-18, 7:10 pm

math.idiot@gmail.com skrev:
> (display "------------------------")(display #\newline)
> (display (eq? (* 2 2) (sqrt 16)))(display #\newline)
> (display (eq? (cons 1 2) (cons (- 2 1) (+ 1 1))))(display #\newline)
> (display (eqv? (* 2 2) (sqrt 16)))(display #\newline)
> (display (eqv? (cons 1 2) (cons (- 2 1) (+ 1 1))))(display #\newline)
> (define x (/ 5 7))
> (define y (/ 5 7))
> (display (eq? x y))(display #\newline)
> (display (eqv? x y))(display #\newline)
> (display (equal? 3 (/ 6 2)))(display #\newline)
> (display (equal? 3 (/ 6 2.0)))(display #\newline)
> (display (equal? '(1 2 3) '(1 2 3)))(display #\newline)
>
> All versions are latest as of yesterday.
> mzscheme:
> #t #f #t #f #f #t #t #f #t
> scheme48:
> #f #f #f #f #f #t #t #f #t
> guile:
> #f #f #f #f #f #t #t #f #t
> bigloo:
> #f #f #f #f #f #t #t #f #t
> gambit:
> #t #f #t #f #f #t #t #f #t
> larceny:
> #f #f #f #f #f #t #t #f #t


Looks fine to me.

Did you expect anything else?

--
Jens Axel Søgaard
Bruce Lewis

2007-03-18, 7:10 pm

eq? tests if its operand are the same object. Implementations have
plenty of latitude as to when this might or might not be true.

Similarly, you're exploring situations where the result of eqv? is left
undefined for good reasons.
Ray Dillinger

2007-03-19, 7:19 pm

Are you upset that behavior the standard specifically
leaves undefined, may vary between implementations?

Bear

Pascal Bourguignon

2007-03-20, 4:27 am

Ray Dillinger <bear@sonic.net> writes:

> Are you upset that behavior the standard specifically
> leaves undefined, may vary between implementations?


Not for these functions. When you want to test for equality of values
independently of the implementation, you can use a predicate that is
defined to behave the same everywhere. Why would you use eq? on
numbers if you want to write an implementation independant program?

--
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org
Erencetard7

2007-03-20, 9:42 am

Catherine Zeta Jone Throatjob!
http://Catherine-Zeta-Jone-Throatjo...hp?movie=148803
Ray Dillinger

2007-03-21, 5:44 am

Pascal Bourguignon wrote:

> Not for these functions. When you want to test for equality of values
> independently of the implementation, you can use a predicate that is
> defined to behave the same everywhere. Why would you use eq? on
> numbers if you want to write an implementation independant program?


Right... that's why we have =, the numeric-comparison operator.

Bear

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com