2.4.11 Bool-Vector Type
A bool-vector is a one-dimensional array whose elements 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.
(make-bool-vector 3 t)
β #&3"^G"
(make-bool-vector 3 nil)
β #&3"^@"
These results make sense, because the binary code for βC-g
β is 111 and βC-@
β is the character with code 0.
If the length is not a multiple of 8, the printed representation shows extra elements, but these extras really make no difference. For instance, in the next example, the two bool-vectors are equal, because only the first 3 bits are used:
(equal #&3"\377" #&3"\007")
β t