hashtable-set!(3scm)
π hashtable-set!(3scm) β the one where you change an association in a hashtable
okay so bestie, welcome to the Scheme Programmer's Manual β¨ and honestly? this page is short and sweet and it's gonna change your whole day, no cap.
πΈ NAME πΈ
hashtable-set! β change an association in a hashtable π
π LIBRARY π
import it one of these ways, iykyk:
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
β¨ SYNOPSIS β¨
(hashtable-set! hashtable key obj)
that's it. three arguments. main character energy fr fr π
π DESCRIPTION π
so what it does is it changes hashtable so that it associates key with obj β like, it either adds a brand new association, or it replaces whatever association was already there for key. it's giving "out with the old, in with the new" π and it literally does not care which one it's doing, it just handles it π
π§ IMPLEMENTATION NOTES π§
okay so lowkey this is important: calling this procedure can trigger growth of the hashtable, and when that happens it can require all keys to be hashed again π like the whole squad gets re-hashed. just so you know. π«Ά
β RETURN VALUES β
returns unspecified values. that's it. nothing to see here, no cool little result to show off, it's just vibes π¦
π EXAMPLES π
here's the whole cute little scenario:
(define ht (make-eq-hashtable))
(hashtable-set! ht 'foo 'bar)
(hashtable-ref ht 'foo #f) => bar
look at that. bar came back. ate. π
π₯ COMPATIBILITY π₯
this procedure is unique to R6RS β like, it's its thing. but similar procedures do exist in SRFI-69 and SRFI-125, so if you're slumming it in a different SRFI you're not totally stranded, bestie π
π ERRORS π
this procedure can raise exceptions with these condition types:
&assertion(R6RS) β this one hits when you passed the wrong number of arguments, or when an argument was outside its domain. specifically: hashtable should actually be a hashtable, and key should be in the domain of the hashtable's hash and equal functions. so like. use it right. π
π¦ SEE ALSO π¦
make-hashtable(3scm)hashtable-ref(3scm)
(the holy trinity honestly π)
π STANDARDS π
R6RS. periodt. π
π HISTORY π
this procedure first appeared in R6RS. and fun fact: an equivalent procedure already existed in SRFI-69 under the name hash-table-set!. so it's not even a new idea, it just got a glow-up β¨
π§ 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/ π«Ά
no cap, that's the whole page. go forth and set some keys, bestie π
okay and finally, the cute little sign-off: this gem dropped on 2023-01-22, straight from the Scheme Programmer's Manual, and it's hashtable-set!(3scm) through and through ππβ¨
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2023 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms