From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.lisp.guile.user Subject: Re: logical shift operators in guile? Date: Thu, 10 Jun 2010 14:32:15 +0200 Message-ID: <87pqzzxe40.fsf@ambire.localdomain> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1276173282 10292 80.91.229.12 (10 Jun 2010 12:34:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 10 Jun 2010 12:34:42 +0000 (UTC) Cc: Guile Mailing List To: steve tell Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jun 10 14:34:40 2010 connect(): No such file or directory Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OMgy0-0002Zx-20 for guile-user@m.gmane.org; Thu, 10 Jun 2010 14:34:40 +0200 Original-Received: from localhost ([127.0.0.1]:58822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMgxz-00022Q-CL for guile-user@m.gmane.org; Thu, 10 Jun 2010 08:34:39 -0400 Original-Received: from [140.186.70.92] (port=55347 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMgxs-00022I-U7 for guile-user@gnu.org; Thu, 10 Jun 2010 08:34:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMgxr-0007bz-3z for guile-user@gnu.org; Thu, 10 Jun 2010 08:34:32 -0400 Original-Received: from smtp205.alice.it ([82.57.200.101]:53257 helo=smtp205-alice.cp.alice.it) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMgxq-0007bS-Rp for guile-user@gnu.org; Thu, 10 Jun 2010 08:34:31 -0400 Original-Received: from ambire.localdomain (95.236.70.202) by smtp205-alice.cp.alice.it (8.5.124.05) id 4C0E61C9001406D2; Thu, 10 Jun 2010 14:34:23 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.69) (envelope-from ) id 1OMgvf-0008NR-OB; Thu, 10 Jun 2010 14:32:15 +0200 In-Reply-To: (steve tell's message of "Wed, 9 Jun 2010 00:04:41 -0400 (EDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7859 Archived-At: () steve tell () Wed, 9 Jun 2010 00:04:41 -0400 (EDT) But is there any way to copy the contents of bitvector a to another bitvector b of the same size, short of iterating over the elements? You can use =E2=80=98bit-set*!=E2=80=99, something like: (define (copy-bit-vector orig) (let ((copy (make-uniform-vector (uniform-vector-length orig) #t))) (bit-invert! copy) (bit-set*! copy orig #t) copy)) (write-line (copy-bit-vector #*111111111111111)) #*111111111111111 This uses Guile 1.4.x-isms for constructing the bit vector; YMMV. Here is a more elegant variant that does not work under Guile 1.4.1.118, even though it should (a bug): (define (copy-bit-vector orig) (let ((copy (make-uniform-vector (uniform-vector-length orig) #t))) (bit-set*! copy orig #f) copy)) The first variant creates all-1s, "manually" inverts, then does a logical O= R. The second creates all-1s, then does a logical AND-NOT. BTW, to answer the previous question (re shift), you can avoid shifting by specifying a non-bitvec uniform vector as the second arg to =E2=80=98bit-se= t*!=E2=80=99. thi