hashtable-copy - copy a hashtable
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
(hashtable-copy hashtable)
(hashtable-copy hashtable mutable)
Returns a copy of hashtable.
If the mutable argument is provided and is true, the
returned hashtable is mutable; otherwise it is immutable.
Returns a single value; a hashtable.
(define (alist->eqv-hashtable alist)
(let ((ht (make-eqv-hashtable)))
(do ((alist alist (cdr alist)))
((null? alist)
(hashtable-copy ht))
(hashtable-set! ht (caar alist) (cdar alist)))))
(hashtable-entries
(alist->eqv-hashtable '((0 . zero) (1 . one) (2 . three))))
=> #(0 1 2)
#(zero one three)
Allowing the hashtable to be immutable allows implementations to create an
optimized representation for the hashtable.
This procedure is unique to R6RS.
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 must be a hashtable.
This procedure first appeared in R6RS, but a similar procedure was also present
in SRFI-69.