hash-has-key
This commit is contained in:
parent
d75e72d476
commit
2e077e257d
|
@ -99,8 +99,11 @@
|
|||
'make-immutable-hasheqv
|
||||
'make-immutable-hasheq
|
||||
'hash-ref
|
||||
'hash-has-key?
|
||||
'hash-set!
|
||||
'hash-set
|
||||
'hash-remove!
|
||||
'hash-remove
|
||||
'equal-hash-code
|
||||
))
|
||||
(define-predicate KernelPrimitiveName? KernelPrimitiveName)
|
||||
|
|
|
@ -2627,6 +2627,15 @@
|
|||
}
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-has-key?',
|
||||
2,
|
||||
function(M) {
|
||||
var hash = checkHash(M, 'hash-ref', 0);
|
||||
var key = checkAny(M, 'hash-ref', 1);
|
||||
return hash.containsKey(key);
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-set!',
|
||||
3,
|
||||
|
@ -2648,6 +2657,28 @@
|
|||
return hash.functionalPut(key, value);
|
||||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-remove!',
|
||||
2,
|
||||
function(M){
|
||||
var hash = checkMutableHash(M, 'hash-remove!', 0);
|
||||
var key = checkAny(M, 'hash-remove!', 1);
|
||||
hash.remove(key);
|
||||
return VOID;
|
||||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-remove',
|
||||
2,
|
||||
function(M){
|
||||
var hash = checkImmutableHash(M, 'hash-remove', 0);
|
||||
var key = checkAny(M, 'hash-remove', 1);
|
||||
return hash.functionalRemove(key);
|
||||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-has-key?',
|
||||
2,
|
||||
|
|
|
@ -161,6 +161,8 @@
|
|||
hash-ref
|
||||
hash-set!
|
||||
hash-set
|
||||
hash-remove!
|
||||
hash-remove
|
||||
equal-hash-code
|
||||
|
||||
|
||||
|
@ -497,7 +499,11 @@ symbol->string
|
|||
placeholder-set!
|
||||
|
||||
eof-object?
|
||||
read-byte)
|
||||
read-byte
|
||||
|
||||
|
||||
hash-has-key?
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,3 +36,15 @@ true
|
|||
danny
|
||||
dyoo@hashcollision.org
|
||||
unknown
|
||||
not-there
|
||||
two
|
||||
one
|
||||
two
|
||||
not-there
|
||||
two
|
||||
|
||||
"hash-has-key"
|
||||
false
|
||||
true
|
||||
false
|
||||
true
|
||||
|
|
|
@ -92,3 +92,30 @@
|
|||
(displayln (hash-ref ht 'name "unknown"))
|
||||
(displayln (hash-ref ht 'email "unknown"))
|
||||
(displayln (hash-ref ht 'phone "unknown")))
|
||||
|
||||
|
||||
|
||||
(let ([ht (make-hash '((1 . one)
|
||||
(2 . two)))])
|
||||
(hash-remove! ht 1)
|
||||
(displayln (hash-ref ht 1 'not-there))
|
||||
(displayln (hash-ref ht 2 'not-there)))
|
||||
|
||||
(let* ([ht (make-immutable-hash '((1 . one)
|
||||
(2 . two)))])
|
||||
(hash-remove ht 1)
|
||||
(displayln (hash-ref ht 1 'not-there))
|
||||
(displayln (hash-ref ht 2 'not-there)))
|
||||
|
||||
(let* ([ht (make-immutable-hash '((1 . one)
|
||||
(2 . two)))]
|
||||
[ht (hash-remove ht 1)])
|
||||
(displayln (hash-ref ht 1 'not-there))
|
||||
(displayln (hash-ref ht 2 'not-there)))
|
||||
|
||||
(newline)
|
||||
"hash-has-key"
|
||||
(hash-has-key? (make-hash) 1)
|
||||
(hash-has-key? (make-hash '((1 . one))) 1)
|
||||
(hash-has-key? (make-immutable-hash) 1)
|
||||
(hash-has-key? (make-immutable-hash '((1 . one))) 1)
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
|
||||
(provide version)
|
||||
(: version String)
|
||||
(define version "1.60")
|
||||
(define version "1.61")
|
||||
|
|
Loading…
Reference in New Issue
Block a user