hashtable-size(3scm)
β¨ hashtable-size β it's giving "how many keys are in this thing" β¨
okay so bestie, this is the hashtable-size page from the Scheme Programmer's Manual (that's the (3scm) part, iykyk) π
and honestly it's a short one, so grab your boba and let's go π§π
πΈ LIBRARY πΈ
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
two ways to get at her, both R6RS, both slay β¨
π SYNOPSIS π
(hashtable-size hashtable)
one argument, one lil' call, that's the whole vibe π«Ά
π DESCRIPTION π
Returns the number of keys contained in hashtable. that's it. that's the procedure. she's a counter, she's not dramatic, she just knows things π
β RETURN VALUES β
Returns a single value β an exact non-negative integer object. literally cannot be negative, cannot be inexact, she's an exact non-negative integer and she's proud of it π
π¦ EXAMPLES π¦
okay this one's a little nested-do moment but stay with me, it eats:
(map (lambda (n)
(do ((ht (make-eqv-hashtable))
(i 0 (+ i 1)))
((> i n)
(hashtable-size 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 11 12 13))
=> (1 2 4 7 10 15 19 26 31 37 43 54 60 73)
like, look at those numbers climbing, no cap, she's growing π±π₯
π COMPATIBILITY π
This procedure is unique to R6RS. similar procedures exist in SRFI-69 and SRFI-125 (so like, cousins, not twins), so if you're porting code around, mind the name differences π
π 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 hashtable. like, she needs an actual hashtable, bestie, don't hand her a list and expect magic π
π SEE ALSO π
make-hashtable(3scm)hashtable-keys(3scm)hashtable-entries(3scm)
go read those next, they're the friend group π«Άβ¨
π§ STANDARDS π§
R6RS π
π₯ HISTORY π₯
This procedure first appeared in R6RS. An equivalent procedure already existed in SRFI-69 under the name hash-table-size β so she's got lore, she's got heritage, she's an icon π
π
πΈ 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/.
okay that's the whole page, short and sweet and honestly? she ate ππ this lil' cutie is dated 2023-01-22 and lives in the scheme-manpages collection β now go count some keys, bestie, mwah ππ¦
π¦ 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