2017-08-27

(sph hashtable)

hashtable processing

part of sph-lib

maturity: medium

status: should work

example

(symbol-hashtable a 1 b 2)

bindings

library description

syntax

  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)

exports

ht-alist

procedure

signature

ht [depth] ->

rnrs-hashtable [integer] -> list

description

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

ht-bind

syntax

signature

ht (key ...) body ...

ht-clear!

procedure

signature

hashtable [k] ->

ht-contains?

procedure

signature

hashtable key ->

ht-copy

procedure

signature

hashtable [mutable] ->

ht-copy*

procedure

signature

a proc ->

description

call proc with a copy of hashtable and return it

ht-copy-empty

procedure

signature

a ->

hashtable -> hashtable

description

creates a new empty hashtable with the same equivalence and hash function as the input hashtable.

ht-create

procedure

signature

associations ... ->

description

{key value} ... -> hashtable

creates a hashtable.

example: (hashtable 'a 1 'b 2 'c 3)

ht-create-binding

syntax

ht-create-eq

syntax

ht-create-eqv

syntax

ht-create-string

syntax

ht-create-symbol

syntax

ht-delete!

procedure

signature

hashtable key ->

ht-each

procedure

signature

proc ht ->

procedure:{key value ->} hashtable ->

description

call proc for each key and value association in hashtable

ht-each-key

syntax

signature

proc ht

ht-entries

procedure

signature

hashtable ->

ht-equivalence-function

procedure

signature

hashtable ->

ht-fold

procedure

signature

proc init a ->

procedure:{key value state -> state} any hashtable -> list

ht-fold-right

procedure

signature

proc init a ->

procedure:{key value state -> state} any hashtable -> list

ht-from-alist

procedure

signature

a [equal-proc hash-proc] ->

description

convert assoc-list/alist "a" to an r6rs hashtable

ht-from-list

procedure

signature

a [equal-proc hash-proc] ->

description

convert a list to an r6rs standard library hashtable. nested lists are not converted to a hash.

example

(ht-ref (ht-from-list (list 'a 1 'b 2)) 'b #f)

-> 2

ht-hash-equal

procedure

signature

obj [size] ->

ht-hash-function

procedure

signature

hashtable ->

ht-hash-string

procedure

signature

a [b c d] ->

ht-hash-symbol

procedure

signature

obj [size] ->

ht-invert!

procedure

signature

a ->

hashtable -> hashtable

description

use values as keys and keys as values

ht-keys

procedure

signature

hashtable ->

ht-make

procedure

signature

hash-function equiv [k] ->

ht-make-eq

procedure

signature

[k] ->

ht-make-eqv

procedure

signature

[k] ->

ht-map!

procedure

signature

proc a ->

hashtable -> hashtable

ht-merge!

procedure

signature

a b ... ->

hashtable hashtable ... -> unspecified

description

copy the values of hash b to hash a. existing key values are overwritten

ht-object

procedure

signature

a [default] ->

hashtable [any:default] -> procedure:{any:key -> any:value/default}

ht-ref

syntax

signature

h k d

ht-ref-q

syntax

signature

h k d

ht-select

procedure

signature

a keys ->

ht-set!

procedure

signature

hashtable key obj ->

ht-set-multiple!

procedure

signature

ht assoc ... ->

description

hashtable key/value ...

return a new hashtable with multiple values having been added or updated

ht-set-multiple-q!

syntax

signature

a key/value ...

ht-set-q!

syntax

signature

h k v

ht-size

procedure

signature

hashtable ->

ht-tree-and-ref

syntax

signature

h k

ht-tree-and-ref-q

syntax

signature

a key ...

ht-tree-contains?

procedure

signature

a keys ... ->

ht-tree-copy

procedure

signature

a ->

ht-tree-copy*

procedure

signature

a proc ->

ht-tree-merge!

procedure

signature

a b ... ->

hashtable ... -> unspecified

description

merges hashtables b from right to left into a. nested hashtables are merged recursively

ht-tree-ref

syntax

signature

h k

ht-tree-ref-q

syntax

signature

a key ...

ht-tree-set!

syntax

signature

h k v

ht-update-multiple!

procedure

signature

ht keys proc ->

hashtable list procedure:{any:values ... -> (any:new-values ...)} -> hashtable

description

set values for "keys" in hashtable to new values by mapping using "proc"

ht-values

procedure

signature

a ->

hashtable -> vector

ht?

procedure

signature

obj ->

sph-hashtable-description

variable

tags: programming guile documentation library scheme sph-lib hashtable sph-hashtable