rif
Nope,
CL-USER 5 > (type-of (map 'vector #'identity #*10110101))
SIMPLE-VECTOR
CL-USER 6 > (equal #*1011011 #*1100111)
NIL
CL-USER 7 > (equal #*1011011 #*1011011)
T
Wade
1. If I want to turn a bit-vector into an index into an array, do I
need an explict accumulating loop?
2. If I want to compare two small (less than a machine word size)
bit-vectors for equality, is it clear that when I use equal, I'm
going to get performance that efficiently uses the underlying
hardware, or am I going to get the equivalent of a loop? The
hyperspec states that when two bit-vectors are compared using
equal, they're compared element-by-element with eql. This is the
right semantics, but one also wants to know that this is as fast
as checking that two numbers are eql. I suspect the answer to
this is implementation dependent.
Cheers,
rif
Let me try to understand this. You want the bit pattern to be converted to
a number, right? EG: #*1001 turns into 9 (decimal)? If so, then I don't
believe we have a built-in function for doing this. You might want to use
fixnums or smaller integers directly, and ldb/dpb etc. via an interface
that is convenient for you for example
(defun get-bit (bits index)
(ldb (byte 1 index) bits))
(defun set-bit (bits index value)
(dpb value (byte 1 index) bits))
(defsetf get-bit set-bit)
CL-USER> #b1001
9
CL-USER> (get-bit 9 1)
0
CL-USER> (set-bit 8 0 1)
9
CL-USER> (setf (get-bit 9 1) 1)
11
CL-USER> ; etc.
If you want efficiency you'll need declarations and such of course.
cheers,
BM