clips - Modifying the current fact that fires a rule -


say have defined template , facts shown below:

(deftemplate student     (slot name (type symbol) (default ?none))     (slot grade (type symbol) (default c) (allowed-symbols b c d))     (slot graduated (type symbol) (default no) (allowed-symbols yes no)) )  (deffacts insert-facts     (student (name george) (grade a))     (student (name nick) (grade c))     (student (name bob))     (student (name mary) (grade b)) ) 

say want create rule checks grade of each student , sets corresponding graduated variable symbol 'yes'. how this?

here's less verbose version of rule came solve problem:

clips>  (deftemplate student     (slot name (type symbol) (default ?none))     (slot grade (type symbol) (default c) (allowed-symbols b c d))     (slot graduated (type symbol) (default no) (allowed-symbols yes no))) clips>  (deffacts insert-facts     (student (name george) (grade a))     (student (name nick) (grade c))     (student (name bob))     (student (name mary) (grade b))) clips>  (defrule rule-1    ?s <- (student (grade a|b) (name ?n) (graduated ~yes))    =>    (modify ?s (graduated yes))    (printout t "congratulations " ?n "!" crlf)) clips> (reset) clips> (run) congratulations mary! congratulations george! clips>  

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -