Given these definitions, what will eq? and equal? return when called on the pairs listed below?
(define s "donut") (define t s) (define l (list 3 4)) (define m (cons 3 '(4))) (define x (car l)) (define y 3)
eq? | equal? | |
|
false false true false false true* true* |
. . . all true . . . |
*Strictly speaking, under R5RS, the result of eq? in these two cases is not specified. For small numeric values, however, most implementations (including our beloved Dr. Scheme) will return true in this case. Using eqv? instead will always return true if the numbers are equal, regardless of how large the number is. See the "Equivalence predicates" section of R5RS for more details.