[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: functional hash operations

From: Paul Jarc
Subject: Re: functional hash operations
Date: Tue, 31 Dec 2002 16:26:53 -0500
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu)

Thien-Thi Nguyen <address@hidden> wrote:
>    From: address@hidden (Paul Jarc)
>    Date: Mon, 30 Dec 2002 18:29:38 -0500
>    "make a copy of this hash which also has this additional entry", etc.
>    It would also be nice to make such copies share as much memory as
>    possible with the original hash.
> check out (ice-9 hcons).

I don't see how that will help me here.  I want something like:
(define (hash-add table key val)
  (let ((new-table (list->vector (vector->list table)))
        (index (hash key (vector-length table))))
    (vector-set! new-table index `((,key . ,val) . ,(vector-ref table index)))

This shares the keys, the values, the association pairs, and the list
pairs between the two tables.  (BTW, is there a better way to copy a

Actually, I'm already writing my own constructors now, and it's easy
enough to reimplement the accessors too; I could avoid the built-in
hash functions altogether (other than hash itself).  As long as I'm at
it, I might as well create the new tables with more appropriate sizes
when they become full.  Is there any convenient way to compute a good
table size, given the number of entries?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]