hashtable-size(3scm) Scheme Programmer's Manual hashtable-size(3scm)

hashtable-size - get the number of associations in a hashtable

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

(hashtable-size hashtable)

Returns the number of keys contained in hashtable.

Returns a single value; an exact non-negative integer object.

(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)

This procedure is unique to R6RS. Similar procedures exist in SRFI-69 and SRFI-125.

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.

make-hashtable(3scm), hashtable-keys(3scm), hashtable-entries(3scm)

R6RS

This procedure first appeared in R6RS. An equivalent procedure already existed in SRFI-69 under the name hash-table-size.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2023-01-22