私は「記号計算にジェントルはじめに」でエクササイズ14.11を行うと、次の関数を書いています:「List型のではありません」というエラー
(defmacro compile-machine (nodes)
`(progn ,@(mapcar #'compile-node nodes)))
*nodes*
がNODE
のリストです(compile-machine *nodes*)
を呼び出します構造は、私は次のエラーを取得する:
Error: *NODES* is not of type LIST.
だから私は*nodes*
は、および
CL-USER 116 > *nodes*
(#<Node START> #<Node HAVE-5> #<Node HAVE-10> #<Node HAVE-15> #<Node HAVE-20> #<Node HAVE-25> #<Node END>)
CL-USER 117 > (type-of *nodes*)
CONS
CL-USER 118 > (listp *nodes*)
T
確かに*nodes*
がリストであるようです。私はここで間違って何をしていますか?
EDIT:複数コードおそらく
(defun compile-arc (arc)
`((equal this-input ',(arc-label arc))
(format t "~&~A" ,(arc-action arc))
(,(node-name (arc-to arc)) (rest input-syms))))
(defun compile-node (node)
`(defun ,(node-name node) (input-syms &aux (this-input (first input-syms)))
(cond ((null input-syms) ',(node-name node))
,@(mapcar #'compile-arc (node-outputs node)) ;isn't this basically the same?
(t (error "No arc from ~A with label ~A." ;and yet Lisp doesn't complain
',(node-name node) this-input)))))
'* nodes *'が指し示すリストをどうやって得ることができますか? – wrongusername
@wrongusername:シンボルがあるときはいつもと同じです。シンボルの値を計算します。 SYMBOL-VALUEまたはEVALを参照してください。 –
ああ、完璧に働いた、ありがとう!しかし、コンパイルノードで 'eval'を使う必要はありませんでしたか?別の関数を呼び出すとこのエラーを防ぐのに役立ちますか? – wrongusername