0

0 1のような出力を取得したいのですが、以下のコードはnilを出力するだけです。type-ofを使用して(最初の16進)をテストします。これは整数です。%dは機能するはずですよね?メッセージを使用すると、Emacsで動作します。

(defun draw-board (board)
  (loop for x below 2
        for hex = (aref board x)
        do (format "%d " (first hex))))

(draw-board [(0 2) (1 2) (0 3) (0 2)])
4

1 に答える 1

6

1-emacslisp形式はCommonLisp形式ではありません。欠落している引数に注意してください!

(format "%d" 42) == (cl:format NIL "~D" 42)

2-したがって、ループが行うことは次のとおりです。

 - to check that board is a vector with at least two slots. (aref
   signals an error if the index is out of bound).

 - to check that each of those two slots are lists (first signals an
   error when passed a non list).

 - to check that the first element of each each of those two slots
   are numbers. (format signals an error when you pass a non number
   for %d).

それで全部です。

何かを印刷したいと言ったことは一度もありません。

何かを印刷するには、それをバッファーに入れ、ps-print-bufferを使用する必要があります。

(defun draw-board (board)
  (with-temp-buffer
    (loop for x below 2
          for hex = (aref board x)
          do (insert (format "%d " (first hex))))
    (ps-print-buffer)))
于 2012-06-18T03:34:14.657 に答える