This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see GeneralizedEqualCowan in WG2's repo for R7RS-large.

Generalized­Equal­Cowan

cowan
2012-11-29 05:57:49
1history
source

Generalized equal? predicate

(generalized-equal? obj1 obj2 [ = [ string=? [ char=? [ symbol=? [ recursive=? ] ] ] ] ] )

Compares obj1 and obj2 for equality. If both are pairs, vectors, or bytevectors, or belong to the same implementation-defined container types, returns #t if they are equal in length and the same call to generalized-equal? returns #t on all the components. If both are numbers, they are compared with the procedure =; if both are characters, they are compared with the procedure char=?; if both are strings, they are compared with the procedure string=?; if both are symbols, they are compared with the procedure symbol=?. The default values of these are =, char=?, string=?, and symbol=? respectively.

In all other cases, the procedure recursive=? is invoked with three arguments: obj1, obj2, and a two-argument procedure which returns what generalized-equal? returns given the seven arguments passed to or defaulted on it in this call. This allows recursive=? to return whatever it likes on atomic types it knows about, and to invoke its third argument on the components of composite types it knows how to descend into. It is recommended that when recursive=? receives arguments it does not know how to handle, that it invokes eqv? on them. The default value of recursive=? always applies eqv? to its first two arguments.