#t if object is a bit string; otherwise returns
Returns the length of bit-string.
#t if the kth bit is 1; otherwise returns
#f. K must be a valid index of bit-string.
Sets the kth bit in bit-string to 1 and returns an unspecified value. K must be a valid index of bit-string.
Sets the kth bit in bit-string to 0 and returns an unspecified value. K must be a valid index of bit-string.
Returns the index of the first occurrence of a set bit in the substring
of bit-string from start (inclusive) to end
(exclusive). If none of the bits in the substring are set
returned. The index returned is relative to the whole bit string, not
The following procedure uses
find all the set bits and display their indexes:
(define (scan-bitstring bs) (let ((end (bit-string-length bs))) (let loop ((start 0)) (let ((next (bit-substring-find-next-set-bit bs start end))) (if next (begin (write-line next) (if (< next end) (loop (+ next 1)))))))))