Next: , Previous: Char-Table Type, Up: Programming Types


2.3.11 Bool-Vector Type

A bool-vector is a one-dimensional array of elements that must be t or nil.

The printed representation of a bool-vector is like a string, except that it begins with ‘#&’ followed by the length. The string constant that follows actually specifies the contents of the bool-vector as a bitmap—each “character” in the string contains 8 bits, which specify the next 8 elements of the bool-vector (1 stands for t, and 0 for nil). The least significant bits of the character correspond to the lowest indices in the bool-vector. If the length is not a multiple of 8, the printed representation shows extra elements, but these extras really make no difference.

     (make-bool-vector 3 t)
          => #&3"\007"
     (make-bool-vector 3 nil)
          => #&3"\0"
     ;; These are equal since only the first 3 bits are used.
     (equal #&3"\377" #&3"\007")
          => t