guoqi.txt
来自「CLIPS是一个专家系统」· 文本 代码 · 共 39 行
TXT
39 行
;我在学习clips,所以来练习一下,以下代码实现了基本功能
(deftemplate stationcolors
(slot station (type STRING) (default ?DERIVE))
(multislot colors (type SYMBOL) (default ?DERIVE))
)
(deffacts stationcolors_list
(stationcolors (station "United States ") (colors red white blue))
(stationcolors (station "Belgium ") (colors black yellow red))
(stationcolors (station "Poland ") (colors white red))
(stationcolors (station "Monaco ") (colors white red))
(stationcolors (station "Sweden ") (colors yellow blue))
(stationcolors (station "Panama ") (colors red white blue))
(stationcolors (station "Jamaica ") (colors black yellow green))
(stationcolors (station "Colombia ") (colors yellow blue red))
(stationcolors (station "Italy ") (colors green white red))
(stationcolors (station "Ireland ") (colors green white orange))
(stationcolors (station "Greece ") (colors blue white))
(stationcolors (station "Botswans ") (colors blue white black))
)
(defrule startup
=>
(printout t "Please input a color : " )
(assert (color (read) ) )
)
(defrule check_color
(color ?color-read)
(stationcolors (station ?station) (colors $?colors))
=>
(bind ?lenColors (length ?colors))
(loop-for-count (?count1 1 ?lenColors) do
( if (eq ?color-read (nth$ ?count1 ?colors)) then
(printout t ?station " : " ?colors crlf )
)
)
)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?