[plt-scheme] eqv? equal?

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Sun Mar 1 15:01:11 EST 2009

 >     emre berat nebiog(lu skrev:
 >
 >         Sorry for this newbie question.But i wonder so much about eqv?
 >         and equal?.In the some discussin that passes on ffreenode
 >         #scheme.I see some sentence which is "eqv? is faster than equal?
 >         in comparison.So i thought eqv? and equal? returns boolean thing
 >         #t or #f right ? So why?
 >
 >         In that point,i have three question about that.
 >
 >         what is the thing that makes eqv? faster than equal?.
 >
 >         which one is more powerful on programming  ?
 >
 >         What is the reason that equal? still be used ? If eqv? is faster
 >         than equal?.
 >
 >
 >     Read:
 >
 > 
http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_sec_6.1
 >
 >     Try to predict the result of:
 >
 >      (eqv? (list 1 2) (list 1 2))
 >
 >     and
 >
 >      (equal? (list 1 2) (list 1 2))
 >
 >
 >     What happens and why?


emre berat nebiog(lu skrev:
> eqv returns false.
> 
> equal returns true.
> 
> i learn new things so eqv? and equal? is not the same thing.But i cannot 
> thing anything about that I read the link..


The short answer:

(eqv? p1 p2) checks whether p1 and p2 is the same pair
(i.e. located the same place in memory - and thus is a simple
pointer comparision)

(equal? p1 p2) checks recursively whether the contents of the
the car and cdr of the pairs are the same.

-- 
Jens Axel Søgaard


Posted on the users mailing list.