# 2.4.11 布尔向量类型

布尔向量 是 lisp 一维数组，其数组元素只能是 t 或 nil。

布尔向量的打印表示和字符串很像。不过布尔向量的打印表示的最前面比字符串多了 "#&"，后面在跟着向量长度。再紧接的字符串的内容以位图的形式描述了布尔向量的内容。字符串中的每一个字符都包含了8个比特的信息，这8位的信息描述了布尔向量的接下来的8个元素，其中1代表t，0代表nil。字符的最后一位的信息对应了布尔向量最后一个元素。

```
(make-bool-vector 3 t)
    => #&3"^G"
(make-bool-vector 3 nil)
    => #&3"^@"
```

上面这个例子中的结果是正确的，因为 'C-g' 的二进制代码是 111， 而 'C-@' 表示代码 000.

如果打印表示中的字符不是8位的，那么多余的字符便没有任何意义。比如下面这个例子，其中的两个布尔向量是 equal的，因为只有前三个位信息被使用了。

```
(equal #&3"\377" #&3"\007")
     ⇒ t
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://emacs-lisp.ivory.cafe/lisp-shu-ju-lei-xing/bian-cheng-lei-xing/2.4.11-bu-er-xiang-liang-lei-xing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
