C.2.3 创建Y轴标签列

前述函数提供了构建生成垂直轴标签的编号和空字符串列表所需的所有工具:

(defun Y-axis-column (height width-of-label)
  "构建Y轴标签和空字符串的列表。
对于线以上的高度和标签的宽度WIDTH-OF-LABEL。"
  (let (Y-axis)
    (while (> height 1)
      (if (zerop (% height Y-axis-label-spacing))
          ;; 插入标签。
          (setq Y-axis
                (cons
                 (Y-axis-element height width-of-label)
                 Y-axis))
        ;; 否则,插入空白。
        (setq Y-axis
              (cons
               (make-string width-of-label ? )
               Y-axis)))
      (setq height (1- height)))
    ;; 插入基准线。
    (setq Y-axis
          (cons (Y-axis-element 1 width-of-label) Y-axis))
    (nreverse Y-axis)))

在这个函数中,我们从height的值开始,重复减去1。在每次减法之后,我们测试值是否是Y-axis-label-spacing的整数倍。如果是,我们使用Y-axis-element函数构造一个带有编号的标签;如果不是,我们使用make-string函数构造一个空白标签。基准线由数字1和一个刻度标记组成。