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
.
Create a new bitvector of length len and optionally initialize all elements to fill.
Create a new bitvector with the arguments as elements.
Return the length of the bitvector vec.
Return #t
if the bit at index idx of the bitvector
vec is set (for bitvector-bit-set?
) or clear (for
bitvector-bit-clear?
).
Set (for bitvector-set-bit!
) or clear (for
bitvector-clear-bit!
) the bit at index idx of the bitvector
vec.
Set, clear, or flip all bits of vec.
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 set.
(bitvector-count #*000111000) ⇒ 3
Return a count of how many entries in bitvector are set, with the bitvector bits selecting the entries to consider. bitvector must be at least as long as bits.
For example,
(bitvector-count-bits #*01110111 #*11001101) ⇒ 3
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,
(bitvector-position #*000101 #t 0) ⇒ 3 (bitvector-position #*0001111 #f 3) ⇒ #f
Set entries of bitvector to #t
, with bits selecting
the bits to set. The return value is unspecified. bitvector must
be at least as long as bits.
(define bv (bitvector-copy #*11000010)) (bitvector-set-bits! bv #*10010001) bv ⇒ #*11010011
Set entries of bitvector to #f
, with bits selecting
the bits to clear. The return value is unspecified. bitvector
must be at least as long as bits.
(define bv (bitvector-copy #*11000010)) (bitvector-clear-bits! bv #*10010001) bv ⇒ #*01000010
C API for the corresponding Scheme bitvector interfaces.
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]