【发布时间】:2020-09-16 22:13:34
【问题描述】:
我正在尝试使通用 lisp 等效于这个 UCI Lisp/Interlisp 辅助函数,用于模式数学。
(DRM /? (LAMBDA () (LIST '*VAR* (READ]
文档如下:
-Variables, which are used by the pattern matcher, start with a question mark ("?"), as in ?FOO.
-This is converted internally to (*VAR* role-name), so ?FOO becomes (*VAR* FOO).
-The DRM defines ? to convert itself to *VAR* when it is read
这是我目前的实现:
(set-macro-character #\? (lambda () (list '*var* (read))))
但是当我运行下面的匹配函数时:
(match (ptrans (actor ?x) (object ?x) (to (store)))
(ptrans (actor (person)) (object (person)) (to (store))) nil)
我收到以下来自 DRM 功能的错误:
*** - EVAL/APPLY: too many arguments given to :LAMBDA
我的实现是否正确?
【问题讨论】:
-
该函数应该接受两个参数,但与宏字符关联的 lambda 不接受:有关详细信息和示例,请参阅 clhs.lisp.se/Body/f_set_ma.htm
标签: common-lisp clisp