hashtable-delete!(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’… hashtable-delete! β€” bestie's guide to yeeting an association

ok so you're reading the Scheme Programmer's Manual page for hashtable-delete! and honestly? iconic choice. this is the lil procedure that takes an association out of a hashtable. no drama, no leftovers, just gone. ✨


πŸŽ€ LIBRARY πŸŽ€

import it like this, both work:

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

🌸 SYNOPSIS 🌸

(hashtable-delete! hashtable key)

πŸ’– DESCRIPTION πŸ’–

hashtable-delete! removes any association for key within hashtable. that's it. that's the whole vibe. the association is uninvited from the party and doesn't get to come back unless you set it again, periodt. πŸ’…


πŸ¦‹ RETURN VALUES πŸ¦‹

returns unspecified values. yeah. it's giving "i did the thing, don't ask me what i returned." don't rely on whatever comes back, bestie, it's not for you. πŸ™ˆ


πŸ“ EXAMPLES πŸ“

ok so watch this β€” we set 'foo to 0, then delete 'foo, then delete 'bar (which was never even there, no cap), and the size is...

(let ((ht (make-eq-hashtable)))
  (hashtable-set! ht 'foo 0)
  (hashtable-delete! ht 'foo)
  (hashtable-delete! ht 'bar)
  (hashtable-size ht))
  => 0

0 πŸ”₯ deleting something that isn't there is not a whole crisis, it just doesn't do anything. she's unbothered.


🌈 COMPATIBILITY 🌈

this procedure is unique to R6RS. literally main character energy, she doesn't exist in the other standards. πŸ‘‘


⭐ 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. in particular, hashtable should be a mutable hashtable and key should be in the domain of the hashtable's hash and equal functions. πŸ’€ so yeah, if you hand her an immutable hashtable or a key the hash/equal functions can't handle, she WILL raise the &assertion and you will hear about it.

🧚 SEE ALSO 🧚

  • hashtable-clear!(3scm) β€” the "delete everything" girlie
  • hashtable-set!(3scm) β€” the "put it back in" girlie

πŸ’œ STANDARDS πŸ’œ

R6RS. that's the standard, that's the rule, that's the whole situation. 🫢


🌸 HISTORY 🌸

this procedure first appeared in R6RS. an equivalent procedure can be found in SRFI-69 under the name hash-table-delete! β€” so if you're hanging out over there, she's going by a different name, iykyk. πŸ¦‹


πŸ‘‘ 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 was hashtable-delete!(3scm) from the Scheme Programmer's Manual, dated 2023-01-22. go forth and delete responsibly (or don't β€” deleting a nonexistent key is literally fine). slay. βœ¨πŸŽ€

πŸ“¦ where this page comes from