hashtable-clear!(3scm)

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

✨ NAME ✨

Okay so hashtable-clear! from the Scheme Programmer's Manual β€” page tag hashtable-clear!(3scm) β€” is here to remove all entries from a hashtables ✨ (yes, the original says β€œa hashtables,” and we are keeping that exact line, periodt πŸ’…).

πŸ“š LIBRARY πŸ“š

These are the imports, bestie β€” both tagged ;R6RS:

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

πŸͺ„ SYNOPSIS πŸͺ„

(hashtable-clear! hashtable)
(hashtable-clear! hashtable k)

πŸ’– DESCRIPTION πŸ’–

It removes all associations from hashtable. Like, every single one. Gone. Slay. πŸ’…

If you give it a second argument, the current capacity of the hashtable is reset to approximately k elements. That's the whole tea, fr fr.

πŸŽ€ RETURN VALUES πŸŽ€

This procedure returns unspecified values. No promised useful return value, bestie β€” it's giving side-effect main character energy. ✨

🌸 EXAMPLES 🌸

Vibe check: make an eq hashtable, set foo to bar, clear the whole thing, then check the size β€” and boom, it's 0:

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

🚨 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 k should be an exact non-negative integer.

πŸ‘€ SEE ALSO πŸ‘€

Go check out hashtable-delete!(3scm) β€” it's right there in the same orbit, bestie. πŸ’–

πŸ“œ STANDARDS πŸ“œ

R6RS β€” that's the standard, periodt.

πŸ•°οΈ HISTORY πŸ•°οΈ

This procedure first appeared in R6RS. Iconic since day one. πŸ‘‘

πŸ‘‘ 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/.


Cute sign-off: this page is from the Scheme Programmer's Manual, dated 2023-01-21, page tag hashtable-clear!(3scm) β€” bye bestie, go clear some tables πŸ’–πŸ«Άβœ¨

πŸ“¦ where this page comes from