From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: steve tell <tell@telltronics.org>
Cc: Guile Mailing List <guile-user@gnu.org>
Subject: Re: logical shift operators in guile?
Date: Thu, 10 Jun 2010 14:32:15 +0200 [thread overview]
Message-ID: <87pqzzxe40.fsf@ambire.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.63.1006082248010.3432@ariel.telltronics.org> (steve tell's message of "Wed, 9 Jun 2010 00:04:41 -0400 (EDT)")
() steve tell <tell@telltronics.org>
() 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 ‘bit-set*!’, 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 OR.
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 ‘bit-set*!’.
thi
prev parent reply other threads:[~2010-06-10 12:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-09 4:04 logical shift operators in guile? steve tell
2010-06-09 22:45 ` Andy Wingo
2010-06-10 3:38 ` dsmich
2010-06-10 12:32 ` Thien-Thi Nguyen [this message]
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=87pqzzxe40.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=guile-user@gnu.org \
--cc=tell@telltronics.org \
/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).