如何使用readline绑定剪辑中的多字段值
How to bind multi-field values in clips using readline
我想在 CLIPS 中使用 readline 和 explode$ 分配一个多字段模板。
但是我不知道该怎么做。我是 CLIPS 初学者。
?input <- (explode$ (readline))
(modify ?input (command (first ?input)) (argument (second ?input)))
(assert ?input ))
CLIPS> (clear)
CLIPS> (deftemplate command (slot first) (slot second))
CLIPS>
(defrule example
=>
(printout t "Input? ")
(bind ?input (explode$ (readline)))
(assert (command (first (nth$ 1 ?input))
(second (nth$ 2 ?input)))))
CLIPS> (reset)
CLIPS> (run)
Input? red green
CLIPS> (facts)
f-0 (initial-fact)
f-1 (command (first red) (second green))
For a total of 2 facts.
CLIPS>
我想在 CLIPS 中使用 readline 和 explode$ 分配一个多字段模板。 但是我不知道该怎么做。我是 CLIPS 初学者。
?input <- (explode$ (readline))
(modify ?input (command (first ?input)) (argument (second ?input)))
(assert ?input ))
CLIPS> (clear)
CLIPS> (deftemplate command (slot first) (slot second))
CLIPS>
(defrule example
=>
(printout t "Input? ")
(bind ?input (explode$ (readline)))
(assert (command (first (nth$ 1 ?input))
(second (nth$ 2 ?input)))))
CLIPS> (reset)
CLIPS> (run)
Input? red green
CLIPS> (facts)
f-0 (initial-fact)
f-1 (command (first red) (second green))
For a total of 2 facts.
CLIPS>