hashtable-keys(3scm)
β¨ hashtable-keys β a manual page, but make it cute β¨
Hey bestie π welcome to hashtable-keys(3scm), straight out of the Scheme Programmer's Manual. Yes we're reading a manpage together, yes it's a vibe, no you can't leave yet π«Ά
πΈ NAME πΈ
hashtable-keys β get the keys from a hashtable π
π LIBRARY π
Same deal as always, you import it from whichever flavour of the standard you're living in rn:
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
π¦ SYNOPSIS π¦
(hashtable-keys hashtable)
That's it. One argument. One icon. π
π DESCRIPTION π
Okay so real talk β this procedure hands you back a vector of all the keys chilling inside hashtable. Every single one. The whole squad. π
The way that the ordering is unspecified though β like, do not come for me asking what order they come out in, because the answer is "whatever, it's a mystery." π Don't rely on it, don't build your app on it, just sort it yourself if you care, iykyk.
β RETURN VALUES β
Returns a single value. That value? A vector. One (1) vector. That's the whole personality. π
π₯ EXAMPLES π₯
Here's the code, no cap, exactly as written:
(do ((ht (make-eqv-hashtable))
(n 10)
(i 0 (+ i 1)))
((> i n)
(vector-sort < (hashtable-keys ht)))
(do ((j 0 (+ j 1)))
((> j n))
(hashtable-set! ht (* i j) #t)))
=> #(0 1 2 3 4 5 6 7 8 9 10 12 14 15 16 18 20
21 24 25 27 28 30 32 35 36 40 42 45 48 49 50
54 56 60 63 64 70 72 80 81 90 100)
Look at that output ate π― β it's literally the multiplication-table keys all sorted because the example called vector-sort, not because the procedure promised you anything about ordering. Reminder from your girl: order is unspecified. π
π COMPATIBILITY π
This one is unique to R6RS β main character energy, no shared universe. Similar procedures do exist elsewhere though: SRFI-69 and SRFI-125 got their own versions. So if you're porting, bestie, check your imports. π§
π ERRORS π
Yeah it can raise exceptions, and here's the condition type to catch:
&assertion(R6RS) β thrown when you passed the wrong number of arguments, or an argument was outside its domain. Specifically:hashtablehas to be a hashtable. Like, babe, it's in the name. π Pass it something that isn't one and it's over.
π SEE ALSO π
hashtable-entries(3scm)β the sibling page, go read it next π«Ά
π STANDARDS π
R6RS β β that's the one, that's the source.
π HISTORY π
This procedure first appeared in R6RS. But plot twist: an equivalent procedure already existed in SRFI-69, and it was going by the name hash-table-keys the whole time. Not me finding out my fave has an older sibling π
πΈ AUTHORS πΈ
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More info lives at https://github.com/schemedoc/manpages/ β go snoop, it's giving documentation royalty β¨
and that's the whole page bestie, mwah π β brought to you by the version tagged 2023-01-22, hashtable-keys(3scm) edition. Periodt. π
π¦ 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