From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Christopher Cramer Newsgroups: gmane.lisp.guile.user Subject: Re: functional hash operations Date: Tue, 31 Dec 2002 18:48:36 -0600 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <20021231184836.A22199@kiwi.pyrotechnics.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1041382000 13712 80.91.224.249 (1 Jan 2003 00:46:40 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 1 Jan 2003 00:46:40 +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 18TX1q-0003Yv-00 for ; Wed, 01 Jan 2003 01:46:38 +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 18TX0D-0000ca-01 for guile-user@m.gmane.org; Tue, 31 Dec 2002 19:44:57 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18TWzt-0000Uf-00 for guile-user@gnu.org; Tue, 31 Dec 2002 19:44:37 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18TWzj-0000Kr-00 for guile-user@gnu.org; Tue, 31 Dec 2002 19:44:30 -0500 Original-Received: from pyro.net ([207.7.10.6] helo=kiwi.pyro.net) by monty-python.gnu.org with smtp (Exim 4.10.13) id 18TWzi-0000J7-00 for guile-user@gnu.org; Tue, 31 Dec 2002 19:44:26 -0500 Original-Received: (qmail 22837 invoked by uid 8610); 1 Jan 2003 00:48:36 -0000 Original-To: guile-user@gnu.org Mail-Followup-To: guile-user@gnu.org Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from prj@po.cwru.edu on Tue, Dec 31, 2002 at 04:26:53PM -0500 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:1492 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1492 On Tue, Dec 31, 2002 at 04:26:53PM -0500, Paul Jarc wrote: > (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?) A better way would be to use vector-move-left! or vector-move-right!: (define (vector-copy v) (let* ((len (vector-length v)) (new (make-vector len))) (vector-move-left! v 0 len new 0) new)) But I hope you aren't copying a hash table in time-critical code to begin with. -- Christopher Cramer "All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same way in any country." - Hermann Georing, 1946 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user