I really cant figure out the major difference between eq?, eqv? and equal?
Please explain this.
Besides, why do we need them?
For a technical explanation, take a look at the specification, you won't find a more detailed reference. Or simply check your interpreter's documentation, for example in Racket:
(equal? v1 v2) → boolean?
Two values are
equal?if and only if they areeqv?, unless otherwise specified for a particular datatype. Datatypes with further specification ofequal?include strings, byte strings, pairs, mutable pairs, vectors, boxes, hash tables, and inspectable structures. In the last six cases, equality is recursively defined; if bothv1andv2contain reference cycles, they are equal when the infinite unfoldings of the values would be equal.
(eqv? v1 v2) → boolean?
Two values are
eqv?if and only if they areeq?, unless otherwise specified for a particular datatype. The number and character datatypes are the only ones for whicheqv?differs fromeq?.
(eq? v1 v2) → boolean?
eq?returns#tifv1andv2refer to the same object,#fotherwise. See also Object Identity and Comparisons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With