Go to the first, previous, next, last section, table of contents.


Bit Vectors

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

#b(#f #f #f #t #f #t #f) => #*0001010

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

primitive: bit-count bool bv
Returns the number occurrences of bool in bv.

primitive: 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.

primitive: bit-invert! bv
Modifies bv by replacing each element with its negation.

primitive: bit-set*! bv uve bool
If uve is a bit-vector bv and uve must be of the same length. If bool is #t, 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 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.

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

bv is not modified.


Go to the first, previous, next, last section, table of contents.