Just to add to Oscars answer. There are type specific procedures like string=?
, char=?
, and =
for numbers, but to compare on general there are 3:
eq?
tests if two arguments are the same value, as in created at the same instant or pointer equal.
eqv?
tests if two primitive/scalar/atomic values look the same when displayed
equal?
tests if two values look the same
Also, what is #t
for eq?
is guaranteed to be #t
for eqv?
abd what is #t
for eqv?
is guaranteed to be #t
for equal?
.
I have read books that completely skip eqv?
and just keep eq?
and equal?
as general comparison. A fair amount of procedures that compare stuff have 3 versions of the 3 methods of comparison across the board. Eg. member
(equal?
), memv
(eqv?
), memq
(eq?
).
About eq?
: We are guaranteed that '()
, #t
, #f
and the symbols, like 'test
would evaluate to the same value each and every time so they are always pointer equal. Other values might be, like number between a billion, but you have no guarantee all implementations will do it. (eq? 10 10) ; ==> #f
is correct according to the standard as well as (eq? '(a) '(a)) ; ==> #t
. In fact the two examnples can have any result and it's OK for the report. Notice how I say you are guaranteed to be #t
withe eqv?
if eq?
yuilds #t
but not vice versa. If something is eqv?
you still have no idea what eq?
would be.