From: prj@po.cwru.edu (Paul Jarc)
Subject: Re: functional hash operations
Date: Tue, 31 Dec 2002 16:26:53 -0500 [thread overview]
Message-ID: <m3ptrhria4.fsf@multivac.cwru.edu> (raw)
In-Reply-To: <E18TASu-0000vY-00@giblet.glug.org> (Thien-Thi Nguyen's message of "Mon, 30 Dec 2002 16:41:04 -0800")
Thien-Thi Nguyen <ttn@giblet.glug.org> wrote:
> From: prj@po.cwru.edu (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)))
new-table))
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
vector?)
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?
paul
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2002-12-31 21:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-30 23:29 functional hash operations Paul Jarc
2002-12-31 0:41 ` Thien-Thi Nguyen
2002-12-31 21:26 ` Paul Jarc [this message]
2003-01-01 0:48 ` Christopher Cramer
2003-01-02 6:18 ` Paul Jarc
2002-12-31 12:38 ` Christopher Cramer
2003-01-01 21:47 ` Marius Vollmer
2003-01-02 19:09 ` Paul Jarc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3ptrhria4.fsf@multivac.cwru.edu \
--to=prj@po.cwru.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).