将符号设置为以表形式定义的函数
(defun-q-list-set 'sym list)
参数
sym
命名函数的符号。
list
由函数中要包含的表达式组成的表。
返回值
已定义的 sym。
示例
_$ (defun-q-list-set 'foo '((x) x))
FOO
_$ (foo 3)
3
下面的样例介绍如何使用 defun-q-list-set 把两个函数合并为一个。首先,请在 Visual LISP 控制台窗口中用 defun-q 定义两个函数:
_$ (defun-q s::startup (x) (print x))
S::STARTUP
_$ (defun-q my-startup (x) (print (list x)))
MY-STARTUP
然后使用 defun-q-list-set 将它们合并为一个函数:
_$ (defun-q-list-set 's::startup (append
(defun-q-list-ref 's::startup)
(cdr (defun-q-list-ref 'my-startup))))
S::STARTUP
下面是这些函数分别如何响应,以及使用 defun-q-list-set 合并后函数的工作方式。
_$ (defun-q foo (x) (print (list 'foo x)))
FOO
_$ (foo 1)
(FOO 1) (FOO 1)
_$ (defun-q bar (x) (print (list 'bar x)))
BAR
_$ (bar 2)
(BAR 2) (BAR 2)
_$ (defun-q-list-set
'foo
(append (defun-q-list-ref 'foo)
(cdr (defun-q-list-ref 'bar))
))
FOO
_$ (foo 3)
(FOO 3)
(BAR 3) (BAR 3)
参阅
defun-q 和 defun-q-list-ref 函数。
明经通道 版权所有 未经许可 不得传播 | 评论 |