Changes between Version 4 and Version 5 of GeneralizedEqualCowan
 Timestamp:
 12/01/12 17:15:00 (4 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

GeneralizedEqualCowan
v4 v5 1 1 == Generalized `equal?` predicate == 2 2 3 `(generalizedequal? `''obj1 obj2 comparator'' ...`)`3 `(generalizedequal? `''obj1 obj2'' `.` comparatorlist''`)` 4 4 5 Compares ''obj1'' and ''obj2'' for equality. A ''comparator'' is a procedure that is given two arguments to compare. It returns `#t` if its arguments are to be considered equal, `#f` if they are to be considered unequal, and any other value if it cannot decide. A third argumentconsists of a list of comparators to be used in recursive calls to `generalizeequal?`.5 Compares ''obj1'' and ''obj2'' for equality. A ''comparator'' is a procedure that is given two arguments to compare. It returns `#t` if its arguments are to be considered equal, `#f` if they are to be considered unequal, and any other value if it cannot decide. The third argument of a comparators consists of a list of comparators to be used in recursive calls to `generalizeequal?`. 6 6 7 First, each ''comparator'' argument is invoked on ''obj1'' and ''obj2''. If it returns `#t` or `#f`, that is the result. If all comparators have been invoked without a `#t` or `#f` result, then `generalizedequal?` determines if both ''obj1'' and ''obj2'' are ordered containers of the same type. This determination is partly implementationdependent, but pairs, strings, vectors, and bytevectors must be treated as ordered containers of distinct types. If they are not, then `generalizedequal?` returns what `eqv?` returns on ''obj1'' and ''obj2''. 7 First, each element of ''comparatorlist'' is invoked on ''obj1'' and ''obj2'', passing ''comparatorlist'' as its third argument. If the comparator returns `#t` or `#f`, that is the result. 8 9 If all comparators in the list have been invoked without a `#t` or `#f` result, then `generalizedequal?` determines if both ''obj1'' and ''obj2'' are ordered containers of the same type. This determination is partly implementationdependent, but pairs, strings, vectors, and bytevectors must be treated as ordered containers of distinct types. If they are not both ordered containers of the same type, then `generalizedequal?` returns what `eqv?` returns on ''obj1'' and ''obj2''. 8 10 9 11 Otherwise, if the containers have different numbers of elements, the result is `#f`. Otherwise, `generalizedequal?` invokes itself recursively on each corresponding element of the containers, passing itself the same comparators. If a recursive call returns `#f`, that is the result; if all recursive calls return `#t`, that is the result.