Next: , Previous: , Up: Arrays   [Contents][Index]

5.4.3 Bit Vectors

Bit vectors can be written and read as a sequence of 0s and 1s prefixed by #*.

#1At(#f #f #f #t #f #t #f) ⇒ #*0001010

Some of these operations will eventually be generalized to other uniform-arrays.

Function: bit-count bool bv

Returns the number of occurrences of bool in bv.

Function: bit-position bool bv k

Returns the minimum index of an occurrence of bool in bv which is at least k. If no bool occurs within the specified range #f is returned.

Function: bit-invert! bv

Modifies bv by replacing each element with its negation.

Function: bit-set*! bv uve bool

If uve is a bit-vector, then bv and uve must be of the same length. If bool is #t, then uve is OR’ed into bv; If bool is #f, the inversion of uve is AND’ed into bv.

If uve is a unsigned integer vector, then all the elements of uve must be between 0 and the LENGTH of bv. The bits of bv corresponding to the indexes in uve are set to bool.

The return value is unspecified.

Function: bit-count* bv uve bool


(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t).

bv is not modified.