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

hashtable-entries - get the entries in the hashtable as two vectors

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

(hashtable-entries hashtable)

Returns a vector of the keys in hashtable and a vector of the corresponding values.

Returns two values; two vectors of equal length.

(let ((h (make-eqv-hashtable)))
  (hashtable-set! h 1 'one)
  (hashtable-set! h 2 'two)
  (hashtable-set! h 3 'three)
  (hashtable-entries h))
    => #(1 2 3)
       #(one two three)
            ; entries may be in different order

This procedure is used when iterating over the entries of a hashtable in an indeterminate order or when you need all the associated values from a hashtable.

If a program needs all entries in a hashtable then this procedure is significantly faster than using hashtable-keys(3scm) together with hashtable-ref(3scm) for each key, because it does not need to use the hash and equal functions.

This procedure is unique to R6RS. An equivalent procedure can be found in SRFI-125 under the name hash-table-entries.

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.

hashtable-keys(3scm)

R6RS

This procedure first appeared in R6RS.

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