From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: prj@po.cwru.edu (Paul Jarc) Newsgroups: gmane.lisp.guile.user Subject: Re: functional hash operations Date: Tue, 31 Dec 2002 16:26:53 -0500 Organization: What did you have in mind? A short, blunt, human pyramid? Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1041370236 22563 80.91.224.249 (31 Dec 2002 21:30:36 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 31 Dec 2002 21:30:36 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18TTy6-0005rg-00 for ; Tue, 31 Dec 2002 22:30:34 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18TTxO-000758-0A for guile-user@m.gmane.org; Tue, 31 Dec 2002 16:29:50 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18TTwN-0006OE-00 for guile-user@gnu.org; Tue, 31 Dec 2002 16:28:47 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18TTvw-0005iy-00 for guile-user@gnu.org; Tue, 31 Dec 2002 16:28:21 -0500 Original-Received: from multivac.student.cwru.edu ([129.22.96.25] helo=multivac.cwru.edu) by monty-python.gnu.org with smtp (Exim 4.10.13) id 18TTuz-0004U0-00 for guile-user@gnu.org; Tue, 31 Dec 2002 16:27:21 -0500 Original-Received: (qmail 8099 invoked by uid 500); 31 Dec 2002 21:27:16 -0000 Original-To: guile-user@gnu.org In-Reply-To: (Thien-Thi Nguyen's message of "Mon, 30 Dec 2002 16:41:04 -0800") Mail-Copies-To: nobody Mail-Followup-To: guile-user@gnu.org Original-Lines: 30 User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1491 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1491 Thien-Thi Nguyen 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