Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: Bytevectors, Previous: Vectors, Up: Data Types [Contents][Index]
Bit vectors are zero-origin, one-dimensional arrays of booleans. They
are displayed as a sequence of 0
s and 1
s prefixed by
#*
, e.g.,
(make-bitvector 8 #f) ⇒ #*00000000
Bit vectors are the special case of one dimensional bit arrays, and can thus be used with the array procedures, See Arrays.
Return #t
when obj is a bitvector, else
return #f
.
Return 1
when obj is a bitvector, else return 0
.
Create a new bitvector of length len and optionally initialize all elements to fill.
Like scm_make_bitvector
, but the length is given as a
size_t
.
Create a new bitvector with the arguments as elements.
Return the length of the bitvector vec.
Like scm_bitvector_length
, but the length is returned as a
size_t
.
Return the element at index idx of the bitvector vec.
Return the element at index idx of the bitvector vec.
Set the element at index idx of the bitvector vec when val is true, else clear it.
Set the element at index idx of the bitvector vec when val is true, else clear it.
Set all elements of the bitvector vec when val is true, else clear them.
Return a new bitvector initialized with the elements of list.
Return a new list initialized with the elements of the bitvector vec.
Return a count of how many entries in bitvector are equal to bool. For example,
(bit-count #f #*000111000) ⇒ 6
Return the index of the first occurrence of bool in
bitvector, starting from start. If there is no bool
entry between start and the end of bitvector, then return
#f
. For example,
(bit-position #t #*000101 0) ⇒ 3 (bit-position #f #*0001111 3) ⇒ #f
Modify bitvector by replacing each element with its negation.
Set entries of bitvector to bool, with uvec selecting the entries to change. The return value is unspecified.
If uvec is a bit vector, then those entries where it has
#t
are the ones in bitvector which are set to bool.
uvec and bitvector must be the same length. When
bool is #t
it’s like uvec is OR’ed into
bitvector. Or when bool is #f
it can be seen as an
ANDNOT.
(define bv #*01000010) (bit-set*! bv #*10010001 #t) bv ⇒ #*11010011
If uvec is a uniform vector of unsigned long integers, then they’re indexes into bitvector which are set to bool.
(define bv #*01000010) (bit-set*! bv #u(5 2 7) #t) bv ⇒ #*01100111
Return a count of how many entries in bitvector are equal to bool, with uvec selecting the entries to consider.
uvec is interpreted in the same way as for bit-set*!
above. Namely, if uvec is a bit vector then entries which have
#t
there are considered in bitvector. Or if uvec
is a uniform vector of unsigned long integers then it’s the indexes in
bitvector to consider.
For example,
(bit-count* #*01110111 #*11001101 #t) ⇒ 3 (bit-count* #*01110111 #u32(7 0 4) #f) ⇒ 2
Like scm_vector_elements
(see Vector Accessing from C), but
for bitvectors. The variable pointed to by offp is set to the
value returned by scm_array_handle_bit_elements_offset
. See
scm_array_handle_bit_elements
for how to use the returned
pointer and the offset.
Like scm_bitvector_elements
, but the pointer is good for reading
and writing.
Next: Bytevectors, Previous: Vectors, Up: Data Types [Contents][Index]