(sph hashtable)

rnrs-hashtable processing.

part of sph-lib

library description


  ht-bind :: hashtable (key ...) body ... -> any

    selectively bind keys of hashtable to variables.

    keys are unquoted literals.

    example: (ht-bind my-ht (a b c) (+ 1 c b a))

  ht-ref :: hashtable key [default] -> any

    rnrs ht-ref with an optional default argument

  ht-ref-q :: hashtable hashtable key -> any

    key is implicitly quoted

import name

(sph hashtable)


procedure: ht-alist ht [depth] ->
rnrs-hashtable [integer] -> list
converts a hashtable to an alist. if depth is greater than 0 any other
hashtables being values up to this nesting depth will be converted too.
scheme has a value for infinite that can be used as depth
syntax: ht-bind ht (key ...) body ...
procedure: ht-clear! hashtable [k] ->
procedure: ht-contains? hashtable key ->
procedure: ht-copy hashtable [mutable] ->
procedure: ht-copy* a f ->
call f with a copy of hashtable and return it
procedure: ht-copy-empty a ->
hashtable -> hashtable
creates a new empty hashtable with the same equivalence and hash function as the input hashtable.
procedure: ht-create associations ... ->
{key value} ... -> hashtable
creates a hashtable.
example: (hashtable 'a 1 'b 2 'c 3)
syntax: ht-create-binding
syntax: ht-create-eq
syntax: ht-create-eqv
syntax: ht-create-string
syntax: ht-create-symbol
syntax: ht-create-symbol-q
procedure: ht-delete! hashtable key ->
procedure: ht-each proc ht ->
procedure:{key value ->} hashtable ->
call proc for each key and value association in hashtable
syntax: ht-each-key proc ht
procedure: ht-entries hashtable ->
procedure: ht-equivalence-function hashtable ->
procedure: ht-fold proc init a ->
procedure:{key value state -> state} any hashtable -> list
procedure: ht-fold-right proc init a ->
procedure:{key value state -> state} any hashtable -> list
procedure: ht-from-alist a #:equal-f #:hash-f #:depth ->
list #:equal-f procedure #:hash-f procedure #:depth integer/infinite -> hashtable
convert alist "a" to an r6rs hashtable.
if depth is positive then also convert nested alists to hashtables at most depth nestings deep.
depth can be (inf)
procedure: ht-from-list a [equal-proc hash-proc] ->
convert a list to an r6rs standard library hashtable. nested lists are not converted to a hash.
(ht-ref (ht-from-list (list 'a 1 'b 2)) 'b #f)
-> 2
procedure: ht-from-tree a [equal-proc hash-proc] ->
list [procedure:{a b -> boolean} procedure] -> rnrs-hashtable
like ht-from-list but also converts nested lists to nested hashtables
procedure: ht-hash-equal obj [size] ->
procedure: ht-hash-function hashtable ->
procedure: ht-hash-string a [b c d] ->
procedure: ht-hash-symbol obj [size] ->
procedure: ht-invert! a ->
hashtable -> hashtable
use values as keys and keys as values
procedure: ht-keys hashtable ->
procedure: ht-make hash-function equiv [k] ->
procedure: ht-make-eq [k] ->
procedure: ht-make-eqv [k] ->
procedure: ht-map! proc a ->
hashtable -> hashtable
procedure: ht-merge! a b ... ->
hashtable hashtable ... -> unspecified
copy the values of hash b to hash a. existing key values are overwritten
procedure: ht-object a [default] ->
hashtable [any:default] -> procedure:{any:key -> any:value/default}
syntax: ht-ref h k d
syntax: ht-ref-q h k d
procedure: ht-select a keys ->
procedure: ht-set! hashtable key obj ->
procedure: ht-set-multiple! ht assoc ... ->
hashtable key/value ...
return a new hashtable with multiple values having been added or updated
syntax: ht-set-multiple-q! a key/value ...
syntax: ht-set-q! h k v
procedure: ht-size hashtable ->
syntax: ht-tree-and-ref h k
syntax: ht-tree-and-ref-q a key ...
procedure: ht-tree-contains? a keys ... ->
procedure: ht-tree-copy a ->
procedure: ht-tree-copy* a proc ->
procedure: ht-tree-merge! a b ... ->
hashtable ... -> unspecified
merges hashtables b from right to left into a. nested hashtables are merged recursively
syntax: ht-tree-ref h k
syntax: ht-tree-ref-q a key ...
syntax: ht-tree-set! h k v
procedure: ht-update-multiple! ht keys proc ->
hashtable list procedure:{any:values ... -> (any:new-values ...)} -> hashtable
set values for "keys" in hashtable to new values by mapping using "proc"
procedure: ht-values a ->
hashtable -> vector
procedure: ht? obj ->
variable: sph-hashtable-description