hashtable-contains? - check if a key exists in a hashtable
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
(hashtable-contains? hashtable key)
Returns #t if hashtable contains an association for key,
#f otherwise.
Returns a single value; a boolean object.
(let ((ht (make-eqv-hashtable)))
(hashtable-set! ht (* 7 6) 'answer)
(hashtable-contains? ht 42))
=> #t
This procedure provides a general for checking if hashtables contain certain
keys. If the hashtable never has associations with booleans then another
common solution is to use hashtable-ref(3scm) with #f as the
default value.
This procedure is unique to R6RS.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its
domain.
- R7RS
- The assertions described above are errors. Implementations may signal an
error, extend the procedure's domain of definition to include such
arguments, or fail catastrophically.
This procedure first appeared in R6RS. An equivalent procedure can be found in
SRFI-69 under the name hash-table-exists?.