hashtable-copy - copy a hashtable
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
SYNOPSIS
(hashtable-copy hashtable)
(hashtable-copy hashtable mutable)
DESCRIPTION
Returns a copy of
hashtable.
If the
mutable
argument is provided and is true, the returned hashtable is mutable;
otherwise it is immutable.
RETURN VALUES
Returns a single value; a hashtable.
EXAMPLES
(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)
RATIONALE
Allowing the hashtable to be immutable allows implementations to
create an optimized representation for the hashtable.
COMPATIBILITY
This procedure is unique to R6RS.
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
must be a hashtable.
SEE ALSO
make-hashtable(3scm)
STANDARDS
R6RS
HISTORY
This procedure first appeared in R6RS, but a similar procedure was
also present in SRFI-69.
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/
.
Markup created by unroff 1.0sc, March 04, 2023.