我正在为我的学习创建一个带有 Common Lisp 的专家系统。有一个全局变量:BF -> 事实库。
我这样初始化:
(defvar *BF* NIL)
我的“主函数”调用函数“初始化”,它用大数据设置全局变量。
(defun initialize ()
(setf *BF*
'(
(metric (
(CPU-utilization NIL)
(RPI NIL)
(ART NIL)
(concurent-invocation NIL)
(stall-count NIL)
(GC-bytes-in-use NIL)
(available-thread NIL)
(available-connection NIL)
(instance-count NIL)
))
(problem (
(livelock T)
(memory-leaks T)
(code-inefficient T)
(overload T)
(under-allocation T)
(internal-chokepoint T)
(thread-leaks T)
(blocking-deadlock T)
(unending-retries T)
(overuse-external-system T)
(pig-in-a-python T)
(too-many-layers T)
(backend-bottleneck T)
(frequent-GC-resource-leaks T)
(slow-backend T)
(suddenly-slow-backend T)
(nonblocking-deadlock T)
(thread-leaks T)
))
(category (
(sudden T)
(consistent T)
(periodic T)
(progressive T)
))
)
)
)
在第一次使用此功能时,当我打印BF时,没关系。然后我调用一个修改BF的函数:
(defun apply-rule (type name value)
; Get conclusion list for this rule
(let ((conclusion (get-conclusion name value)))
(if (null conclusion)
(if (not (equal 3 value))
(return-from appliquer-regle NIL)
(return-from appliquer-regle 'T)
)
)
; Iterate on all problems in *BF*
(dolist (e (cadr (assoc 'problem *BF*)))
; If the problem is not in conclusion list, set it value to false
(if (and (member (car e) conclusion) (equal (cadr e) 'T))
()
(setf (cadr e) NIL)
)
)
(return-from apply-rule 'T)
)
(return-from apply-rule NIL)
)
这个功能起作用。但是当我想再次使用“初始化”功能时,它就不起作用了。当我打印BF时,它包含旧值...如何重新初始化我的全局变量?
对不起我的英语,我是法国人^