hashtable-contains?(3scm)

๐Ÿ“ฆ version 0-unstable-2024-02, in nixpkgs unstable

๐Ÿ’… hashtable-contains? โ€” Scheme Programmer's Manual (3scm)

okay so bestie, welcome to the Scheme Programmer's Manual page for hashtable-contains?. this one's short and sweet and honestly kind of a queen. let's get into it ๐ŸŽ€


โœจ NAME

hashtable-contains? โ€” check if a key exists in a hashtable

like, does this table know your guy or not. that's the whole vibe check ๐Ÿ”


๐Ÿ“š LIBRARY

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

both of these get you the goods, no cap ๐Ÿ’–


๐Ÿฆ‹ SYNOPSIS

(hashtable-contains? hashtable key)

๐ŸŒธ DESCRIPTION

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

that's it. that's the whole thing. yes-or-no, in-or-out, slay-or-nay ๐Ÿ’…


โญ RETURN VALUES

Returns a single value; a boolean object. just one (1) little boolean, no extra baggage, we love a minimal icon โœจ


๐Ÿ“ EXAMPLES

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

the way (* 7 6) is literally 42... math ate that ๐Ÿงฎ๐Ÿ”ฅ


๐Ÿ‘‘ 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.

ok so like โ€” this is your general-purpose "is it in there?" tool ๐Ÿซถ. but heads up, bestie: if your hashtable never stores actual booleans, another popular move is calling hashtable-ref(3scm) with #f as the default, and reading the answer off that. just know the difference, iykyk ๐Ÿ’€


๐ŸŒˆ COMPATIBILITY

This procedure is unique to R6RS.

genuinely one of a kind. main character energy, no other standard can claim her ๐Ÿ”ฅ


๐Ÿ’€ 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.
๐Ÿ˜ญ "fail catastrophically" is right there in the spec and we are NOT calm about it. do not pass weird args, bestie. i'm begging ๐Ÿ™ˆ
&assertion (R6RS)

๐Ÿงš 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?.

so she debuted in R6RS, and if you're hanging out in SRFI-69 land you'll find her twin going by hash-table-exists?. same energy, different name, iconic either way ๐Ÿ‘‘


๐Ÿซถ 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/.


and that's the whole page, bestie!! this one's from the Scheme Programmer's Manual, dated 2023-01-121, filed under hashtable-contains?(3scm) โ€” now go check your keys and slay ๐Ÿ’–โœจ๐ŸŒธ

๐Ÿ“ฆ where this page comes from