hashtable-contains? - check if a key exists in a hashtable

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs hashtables))          ;R6RS

SYNOPSIS

(hashtable-contains? hashtable key)

DESCRIPTION

Returns #t if hashtable contains an association for key, #f otherwise.

RETURN VALUES

Returns a single value; a boolean object.

EXAMPLES

(let ((ht (make-eqv-hashtable)))
  (hashtable-set! ht (* 7 6) 'answer)
  (hashtable-contains? ht 42))
    => #t

APPLICATION USAGE

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.

COMPATIBILITY

This procedure is unique to R6RS.

ERRORS

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.

SEE ALSO

hashtable-ref(3scm)

STANDARDS

R6RS

HISTORY

This procedure first appeared in R6RS. An equivalent procedure can be found in SRFI-69 under the name hash-table-exists?.

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.


Markup created by unroff 1.0sc,    March 04, 2023.