hash-equal?

This commit is contained in:
Danny Yoo 2011-11-07 19:13:30 -05:00
parent 4c4d4437b8
commit 36801f7c54
6 changed files with 42 additions and 1 deletions

View File

@ -90,6 +90,7 @@
'prop:exn:srclocs 'prop:exn:srclocs
'hash? 'hash?
'hash-equal?
'hash-eq? 'hash-eq?
'hash-eqv? 'hash-eqv?
'hash 'hash

View File

@ -361,6 +361,10 @@
return (x instanceof WhalesongHashtable || x instanceof WhalesongImmutableHashtable); return (x instanceof WhalesongHashtable || x instanceof WhalesongImmutableHashtable);
}; };
var isHashEqual = function (x) {
return (x instanceof WhalesongHashtable || x instanceof WhalesongImmutableHashtable) && x.type === 'hash';
};
var isHashEqv = function (x) { var isHashEqv = function (x) {
return (x instanceof WhalesongHashtable || x instanceof WhalesongImmutableHashtable) && x.type === 'hasheqv'; return (x instanceof WhalesongHashtable || x instanceof WhalesongImmutableHashtable) && x.type === 'hasheqv';
}; };
@ -437,6 +441,8 @@
exports.makeImmutableEqualHashtable = makeImmutableEqualHashtable; exports.makeImmutableEqualHashtable = makeImmutableEqualHashtable;
exports.isHash = isHash; exports.isHash = isHash;
exports.isHashEqual = isHashEqual;
exports.isHashEqv = isHashEqv; exports.isHashEqv = isHashEqv;
exports.isHashEq = isHashEq; exports.isHashEq = isHashEq;
}(window.plt.baselib, Hashtable)); }(window.plt.baselib, Hashtable));

View File

@ -2524,6 +2524,12 @@
function(M) { function(M) {
return baselib.hashes.isHash(checkAny(M, 'hash?', 0)); return baselib.hashes.isHash(checkAny(M, 'hash?', 0));
}); });
installPrimitiveProcedure(
'hash-equal?',
1,
function(M) {
return baselib.hashes.isHashEqual(checkAny(M, 'hash-equal?', 0));
});
installPrimitiveProcedure( installPrimitiveProcedure(
'hash-eq?', 'hash-eq?',
1, 1,

View File

@ -150,6 +150,7 @@
with-continuation-mark with-continuation-mark
hash? hash?
hash-equal?
hash-eq? hash-eq?
hash-eqv? hash-eqv?
hash hash

View File

@ -27,6 +27,9 @@ not-found
true true
true true
true true
true
false
false
false false
true true
false false
@ -58,3 +61,13 @@ alphabet
1 1
2 2
true
false
false
false
true
false
false
false
true

View File

@ -80,6 +80,9 @@
(hash? (make-immutable-hash)) (hash? (make-immutable-hash))
(hash? (make-immutable-hasheq)) (hash? (make-immutable-hasheq))
(hash? (make-immutable-hasheqv)) (hash? (make-immutable-hasheqv))
(hash-equal? (make-immutable-hash))
(hash-equal? (make-immutable-hasheq))
(hash-equal? (make-immutable-hasheqv))
(hash-eq? (make-immutable-hash)) (hash-eq? (make-immutable-hash))
(hash-eq? (make-immutable-hasheq)) (hash-eq? (make-immutable-hasheq))
(hash-eq? (make-immutable-hasheqv)) (hash-eq? (make-immutable-hasheqv))
@ -137,4 +140,15 @@
(newline) (newline)
(hash-count (make-hash '((a . a)))) (hash-count (make-hash '((a . a))))
(hash-count (make-immutable-hash '((b . b) (hash-count (make-immutable-hash '((b . b)
(c . d)))) (c . d))))
(newline)
(hash-equal? (make-hash))
(hash-equal? (make-hasheq))
(hash-equal? (make-hasheqv))
(hash-eq? (make-hash))
(hash-eq? (make-hasheq))
(hash-eq? (make-hasheqv))
(hash-eqv? (make-hash))
(hash-eqv? (make-hasheq))
(hash-eqv? (make-hasheqv))