【发布时间】:2020-02-16 14:29:11
【问题描述】:
我很好奇是否有办法用逗号插入值后的句点结束反引号符号列表。
这里是示例代码:
(defparameter *things* '(book pencil shoe))
(defun inspect-item (item things)
(if (member item things)
`(you pick up the ,item and yeet it out the window.)
`(only realize the truth... there is no ,item.)))
这将成功(print (inspect-item 'book *things*)),并生成符号列表(YOU PICK UP THE BOOK AND YEET IT OUT THE WINDOW.)。在这种情况下,我假设句点是符号 WINDOW. 的一部分(使用最后一个函数确认)。
但是,这将失败 (print (inspect-item 'spoon *things*)) 声称变量 ITEM. 没有值(因为它认为名称是 item.)。在项目和句点之间留一个空格会给出错误illegal end of dotted list,我认为这是因为它假设我使用的是点列表语法。
有没有办法让它在最后产生我想要的符号(BOOK.)?
【问题讨论】:
标签: common-lisp symbols