(example) ;symbol (example [1]) ;optional (example <INTEGER>) ;replacement <INTEGER>* ;zero or more <INTEGER>+ ;one or more all | none | some ;or
1.5 9.3e+7
5 -37
starts with a printable ASCII character except ? and $? ends with a delimiter, delimiters: non-printable(space, tab, carriage return, or line feed), " ; & | ~ < Examples: Space-Station high_end !?#$^* 678
"!?#$^*" "John S. Liu" "\"Note\"" ;""Note"", '\' as escape character "\\Note\\" ;"\Note\"
C>CLIPS (exit)
( <relation-name> <field>+ ) (person (name "John S. Liu") (age 23) (eye-color brown) (hair-color black))
( deftemplate <relation-name> [<optional-comment>] <slot-definition>* ) <slot-definition> (slot <slot-name>) | (multislot <slot-name>) (deftemplate person (slot name) (slot age) (slot eye-color) (slot hair-color))
(deftemplate person (multislot name) (slot age) (slot eye-color) (slot hair-color)) (person (name John S. Liu) ;multislot (age 23) (eye-color brown) (hair-color black))
(person John S. Liu ;name John 23 ;age brown ;eye-color black) ;hair-color
(assert <fact>+) (assert (person (name John S. Liu) (age 23) (eye-color brown) (hair-color black))) (retract <fact-index>+) (facts) (retract 0)
(modify <fact-index> <slot-modifier>+) <slot-modifier> (<slot-name> <slot-value>) (modify 0 (age 24) ) (facts) (duplicate 2 (name "Jack P. Chen") ) (facts)
(watch <watch-item>) <watch-item> : facts, rules, activations, statistics, compilations, focus, all (watch facts) (modify 3 (age 25) ) (facts)
(deffacts <deffacts name> [<optional comment>] <facts>*) ; initially define a set of facts (reset) reset : 1. remove all activated rules from agenda 2. remove all facts from the fact-list 3. assert the facts from existing deffacts
(defrule <rule-name> [<optional comment>] <patterns>* ;LHS => <actions>* ;RHS ) (defrule fire-emergency "An example rule" ;Rule header (emergency (type fire)) ;Patterns => (assert (response ;Actions (action activate-sprinkler-system))) )
(agenda)Rule and Refraction
(run) (facts) (run) (facts)To make the rule to fire again, use
(refresh <rule-name>) (agenda) (refresh fire-emergency) (agenda)Watching Activations, Rules, and Statistics
(clear) ; remove all facts, rules, and deffacts. (reset) (watch activations) (assert (emergency (type fire))) (agenda) (retract 1) (agenda) (reset) (watch rules) (assert (emergency (type fire))) (run) (agenda) (unwatch all) (watch statistics) (assert (emergency (type fire))) (run)
(list-defrules) (list-deftemplates) (list-deffacts)Displaying the Text Representation of a Specified Construct Member
(ppdefrule <defrule-name>) (ppdeftemplate <deftemplate-name>) (ppdeffacts <deffacts-name>)Deleting a Specified Construct Member
(undefrule <defrule-name>) (undeftemplate <deftemplate-name>) (undeffacts <deffacts-name>)
(printout <logical-name> <print-items>*) (defrule fire-emergency (emergency (type fire)) => (printout t "action activate-sprinkler-system" crlf))
Example:
(set-break <rule-name>) (show-breaks) (remove-break <rule-name>)Example
(load "xmp.clp") (load "c:\\clips\\xmp.clp") ;use \\ for backslashWatching Compilations
(watch compilations) (load "c:\\clips\\xmp.clp")Saving Constructs to a File
(save "xmp.clp")
; (emergency < type >)
Previous Clips Overview Up TOC Next Pattern Matching