TRUE CLIPS> (batch "fctquery.bat") TRUE CLIPS> (reset) CLIPS> (do-for-all-facts ((?i MAN)) TRUE (+ (eval "(gensym)") 2)) [ARGACCES2] Function '+' expected argument #1 to be of type integer or float. FALSE CLIPS> (do-for-all-facts ((?mb MALE) (?wg FEMALE)) TRUE (printout t ?mb:name " " ?wg:name crlf)) [Boy-1] [Girl-1] [Boy-1] [Girl-2] [Boy-1] [Woman-1] [Boy-1] [Woman-2] [Boy-1] [Woman-3] [Boy-2] [Girl-1] [Boy-2] [Girl-2] [Boy-2] [Woman-1] [Boy-2] [Woman-2] [Boy-2] [Woman-3] [Boy-3] [Girl-1] [Boy-3] [Girl-2] [Boy-3] [Woman-1] [Boy-3] [Woman-2] [Boy-3] [Woman-3] [Boy-4] [Girl-1] [Boy-4] [Girl-2] [Boy-4] [Woman-1] [Boy-4] [Woman-2] [Boy-4] [Woman-3] [Man-1] [Girl-1] [Man-1] [Girl-2] [Man-1] [Woman-1] [Man-1] [Woman-2] [Man-1] [Woman-3] [Man-2] [Girl-1] [Man-2] [Girl-2] [Man-2] [Woman-1] [Man-2] [Woman-2] [Man-2] [Woman-3] CLIPS> (do-for-all-facts ((?mb BOY MAN) (?wg GIRL WOMAN)) TRUE (progn (printout t ?mb:name ) (printout t " " ?wg:name crlf))) [Boy-1] [Girl-1] [Boy-1] [Girl-2] [Boy-1] [Woman-1] [Boy-1] [Woman-2] [Boy-1] [Woman-3] [Boy-2] [Girl-1] [Boy-2] [Girl-2] [Boy-2] [Woman-1] [Boy-2] [Woman-2] [Boy-2] [Woman-3] [Boy-3] [Girl-1] [Boy-3] [Girl-2] [Boy-3] [Woman-1] [Boy-3] [Woman-2] [Boy-3] [Woman-3] [Boy-4] [Girl-1] [Boy-4] [Girl-2] [Boy-4] [Woman-1] [Boy-4] [Woman-2] [Boy-4] [Woman-3] [Man-1] [Girl-1] [Man-1] [Girl-2] [Man-1] [Woman-1] [Man-1] [Woman-2] [Man-1] [Woman-3] [Man-2] [Girl-1] [Man-2] [Girl-2] [Man-2] [Woman-1] [Man-2] [Woman-2] [Man-2] [Woman-3] CLIPS> (do-for-all-facts ((?f1 FEMALE) (?f2 FEMALE)) TRUE (printout t ?f1:name " " ?f2:name crlf)) [Girl-1] [Girl-1] [Girl-1] [Girl-2] [Girl-1] [Woman-1] [Girl-1] [Woman-2] [Girl-1] [Woman-3] [Girl-2] [Girl-1] [Girl-2] [Girl-2] [Girl-2] [Woman-1] [Girl-2] [Woman-2] [Girl-2] [Woman-3] [Woman-1] [Girl-1] [Woman-1] [Girl-2] [Woman-1] [Woman-1] [Woman-1] [Woman-2] [Woman-1] [Woman-3] [Woman-2] [Girl-1] [Woman-2] [Girl-2] [Woman-2] [Woman-1] [Woman-2] [Woman-2] [Woman-2] [Woman-3] [Woman-3] [Girl-1] [Woman-3] [Girl-2] [Woman-3] [Woman-1] [Woman-3] [Woman-2] [Woman-3] [Woman-3] CLIPS> (do-for-all-facts ((?mb MALE) (?wg FEMALE)) (= (fact-slot-value ?mb age) (fact-slot-value ?wg age)) (printout t ?mb:name " " ?wg:name crlf)) [Boy-1] [Girl-1] [Boy-2] [Girl-2] [Boy-3] [Girl-2] [Boy-4] [Girl-2] [Man-1] [Woman-1] [Man-2] [Woman-2] CLIPS> (do-for-all-facts ((?mb MALE) (?wg FEMALE)) (= ?mb:age ?wg:age) (printout t ?mb:name " " ?wg:name crlf)) [Boy-1] [Girl-1] [Boy-2] [Girl-2] [Boy-3] [Girl-2] [Boy-4] [Girl-2] [Man-1] [Woman-1] [Man-2] [Woman-2] CLIPS> (count-facts WOMAN) 3 CLIPS> (count-facts-2 WOMAN) 3 CLIPS> (count-facts BOY) 4 CLIPS> (count-facts-2 BOY) 4 CLIPS> (any-factp ((?man MAN)) (> ?man:age 30)) TRUE CLIPS> (find-fact ((?m MAN) (?w WOMAN)) (= ?m:age ?w:age)) ( ) CLIPS> (find-all-facts ((?m MAN) (?w WOMAN)) (= ?m:age ?w:age)) ( ) CLIPS> (do-for-fact ((?p1 PERSON) (?p2 PERSON) (?p3 PERSON)) (and (= ?p1:age ?p2:age ?p3:age) (neq ?p1 ?p2) (neq ?p1 ?p3) (neq ?p2 ?p3)) (printout t ?p1:name " " ?p2:name " " ?p3:name crlf)) [Girl-2] [Boy-2] [Boy-3] CLIPS> (do-for-all-facts ((?p1 PERSON) (?p2 PERSON) (?p3 PERSON)) (and (= ?p1:age ?p2:age ?p3:age) (> (str-compare ?p1:name ?p2:name) 0) (> (str-compare ?p2:name ?p3:name) 0)) (printout t ?p1:name " " ?p2:name " " ?p3:name crlf)) [Girl-2] [Boy-3] [Boy-2] [Girl-2] [Boy-4] [Boy-2] [Girl-2] [Boy-4] [Boy-3] [Boy-4] [Boy-3] [Boy-2] CLIPS> (do-for-all-facts ((?p1 PERSON) (?p2 PERSON) (?p3 PERSON)) (= ?p1:age ?p2:age ?p3:age) (printout t ?p1:name " " ?p2:name " " ?p3:name crlf)) [Girl-1] [Girl-1] [Girl-1] [Girl-1] [Girl-1] [Boy-1] [Girl-1] [Boy-1] [Girl-1] [Girl-1] [Boy-1] [Boy-1] [Girl-2] [Girl-2] [Girl-2] [Girl-2] [Girl-2] [Boy-2] [Girl-2] [Girl-2] [Boy-3] [Girl-2] [Girl-2] [Boy-4] [Girl-2] [Boy-2] [Girl-2] [Girl-2] [Boy-2] [Boy-2] [Girl-2] [Boy-2] [Boy-3] [Girl-2] [Boy-2] [Boy-4] [Girl-2] [Boy-3] [Girl-2] [Girl-2] [Boy-3] [Boy-2] [Girl-2] [Boy-3] [Boy-3] [Girl-2] [Boy-3] [Boy-4] [Girl-2] [Boy-4] [Girl-2] [Girl-2] [Boy-4] [Boy-2] [Girl-2] [Boy-4] [Boy-3] [Girl-2] [Boy-4] [Boy-4] [Woman-1] [Woman-1] [Woman-1] [Woman-1] [Woman-1] [Man-1] [Woman-1] [Man-1] [Woman-1] [Woman-1] [Man-1] [Man-1] [Woman-2] [Woman-2] [Woman-2] [Woman-2] [Woman-2] [Man-2] [Woman-2] [Man-2] [Woman-2] [Woman-2] [Man-2] [Man-2] [Woman-3] [Woman-3] [Woman-3] [Boy-1] [Girl-1] [Girl-1] [Boy-1] [Girl-1] [Boy-1] [Boy-1] [Boy-1] [Girl-1] [Boy-1] [Boy-1] [Boy-1] [Boy-2] [Girl-2] [Girl-2] [Boy-2] [Girl-2] [Boy-2] [Boy-2] [Girl-2] [Boy-3] [Boy-2] [Girl-2] [Boy-4] [Boy-2] [Boy-2] [Girl-2] [Boy-2] [Boy-2] [Boy-2] [Boy-2] [Boy-2] [Boy-3] [Boy-2] [Boy-2] [Boy-4] [Boy-2] [Boy-3] [Girl-2] [Boy-2] [Boy-3] [Boy-2] [Boy-2] [Boy-3] [Boy-3] [Boy-2] [Boy-3] [Boy-4] [Boy-2] [Boy-4] [Girl-2] [Boy-2] [Boy-4] [Boy-2] [Boy-2] [Boy-4] [Boy-3] [Boy-2] [Boy-4] [Boy-4] [Boy-3] [Girl-2] [Girl-2] [Boy-3] [Girl-2] [Boy-2] [Boy-3] [Girl-2] [Boy-3] [Boy-3] [Girl-2] [Boy-4] [Boy-3] [Boy-2] [Girl-2] [Boy-3] [Boy-2] [Boy-2] [Boy-3] [Boy-2] [Boy-3] [Boy-3] [Boy-2] [Boy-4] [Boy-3] [Boy-3] [Girl-2] [Boy-3] [Boy-3] [Boy-2] [Boy-3] [Boy-3] [Boy-3] [Boy-3] [Boy-3] [Boy-4] [Boy-3] [Boy-4] [Girl-2] [Boy-3] [Boy-4] [Boy-2] [Boy-3] [Boy-4] [Boy-3] [Boy-3] [Boy-4] [Boy-4] [Boy-4] [Girl-2] [Girl-2] [Boy-4] [Girl-2] [Boy-2] [Boy-4] [Girl-2] [Boy-3] [Boy-4] [Girl-2] [Boy-4] [Boy-4] [Boy-2] [Girl-2] [Boy-4] [Boy-2] [Boy-2] [Boy-4] [Boy-2] [Boy-3] [Boy-4] [Boy-2] [Boy-4] [Boy-4] [Boy-3] [Girl-2] [Boy-4] [Boy-3] [Boy-2] [Boy-4] [Boy-3] [Boy-3] [Boy-4] [Boy-3] [Boy-4] [Boy-4] [Boy-4] [Girl-2] [Boy-4] [Boy-4] [Boy-2] [Boy-4] [Boy-4] [Boy-3] [Boy-4] [Boy-4] [Boy-4] [Man-1] [Woman-1] [Woman-1] [Man-1] [Woman-1] [Man-1] [Man-1] [Man-1] [Woman-1] [Man-1] [Man-1] [Man-1] [Man-2] [Woman-2] [Woman-2] [Man-2] [Woman-2] [Man-2] [Man-2] [Man-2] [Woman-2] [Man-2] [Man-2] [Man-2] CLIPS> (watch facts) CLIPS> (delayed-do-for-all-facts ((?b1 BOY)) (not (any-factp ((?b2 BOY)) (> ?b2:age (fact-slot-value ?b1 age)))) (retract ?b1)) <== f-25 (BOY (name [Boy-1]) (sex male) (age 8)) CLIPS> (unwatch facts) CLIPS> (reset) CLIPS> (watch facts) CLIPS> (do-for-all-facts ((?b1 BOY)) (not (any-factp ((?b2 BOY)) (> ?b2:age (fact-slot-value ?b1 age)))) (retract ?b1)) <== f-25 (BOY (name [Boy-1]) (sex male) (age 8)) <== f-26 (BOY (name [Boy-2]) (sex male) (age 4)) <== f-27 (BOY (name [Boy-3]) (sex male) (age 4)) <== f-28 (BOY (name [Boy-4]) (sex male) (age 4)) CLIPS> (unwatch facts) CLIPS> (reset) CLIPS> (do-for-all-facts ((?b BOY)) TRUE (do-for-all-facts ((?g GIRL)) TRUE (printout t ?b:name " " ?g:name crlf))) [Boy-1] [Girl-1] [Boy-1] [Girl-2] [Boy-2] [Girl-1] [Boy-2] [Girl-2] [Boy-3] [Girl-1] [Boy-3] [Girl-2] [Boy-4] [Girl-1] [Boy-4] [Girl-2] CLIPS> (assert (A (name [a]))) CLIPS> (do-for-all-facts ((?a A)) TRUE (printout t ?a crlf)) CLIPS> (any-factp) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (any-factp TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (any-factp ()) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (any-factp (?B OBJECT) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (any-factp ((?b A))) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (any-factp ((?b BOGUS)) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS'. CLIPS> (any-factp ((?b 34)) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (any-factp ((?b (create$ BOGUS USER))) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS' in function 'any-factp'. [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (any-factp ((?b (create$ USER 34))) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (any-factp ((?b A)) (progn (bind ?b 1) TRUE)) [FACTQPSR2] Binds are not allowed in fact-set query in function any-factp. CLIPS> (find-fact) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-fact TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-fact ()) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-fact (?B OBJECT) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-fact ((?b A))) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-fact ((?b BOGUS)) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS'. CLIPS> (find-fact ((?b 34)) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. () CLIPS> (find-fact ((?b (create$ BOGUS USER))) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS' in function 'find-fact'. [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. () CLIPS> (find-fact ((?b (create$ USER 34))) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. () CLIPS> (find-fact ((?b A)) (progn (bind ?b 1) TRUE)) [FACTQPSR2] Binds are not allowed in fact-set query in function find-fact. CLIPS> (find-all-facts) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-all-facts TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-all-facts ()) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-all-facts (?B OBJECT) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-all-facts ((?b A))) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (find-all-facts ((?b BOGUS)) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS'. CLIPS> (find-all-facts ((?b 34)) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. () CLIPS> (find-all-facts ((?b (create$ BOGUS USER))) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS' in function 'find-all-facts'. [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. () CLIPS> (find-all-facts ((?b (create$ USER 34))) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. () CLIPS> (find-all-facts ((?b A)) (progn (bind ?b 1) TRUE)) [FACTQPSR2] Binds are not allowed in fact-set query in function find-all-facts. CLIPS> (do-for-fact) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-fact TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-fact ()) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-fact (?B OBJECT) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-fact ((?b A))) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-fact ((?b BOGUS)) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS'. CLIPS> (do-for-fact ((?b A)) (progn (bind ?b 1) TRUE)) [FACTQPSR2] Binds are not allowed in fact-set query in function do-for-fact. CLIPS> (do-for-fact ((?b 34)) TRUE abc) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (do-for-fact ((?b (create$ BOGUS USER))) TRUE abc) [PRNTUTIL1] Unable to find deftemplate 'BOGUS' in function 'do-for-fact'. [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (do-for-fact ((?b (create$ USER 34))) TRUE abc) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (do-for-fact ((?b MALE)) TRUE (bind ?b 1)) [FACTQPSR3] Cannot rebind fact-set member variable b in function do-for-fact. CLIPS> (do-for-all-facts) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-all-facts TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-all-facts ()) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-all-facts (?B OBJECT) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-all-facts ((?b A))) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (do-for-all-facts ((?b BOGUS)) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS'. CLIPS> (do-for-all-facts ((?b A)) (progn (bind ?b 1) TRUE)) [FACTQPSR2] Binds are not allowed in fact-set query in function do-for-all-facts. CLIPS> (do-for-all-facts ((?b 34)) TRUE abc) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (do-for-all-facts ((?b (create$ BOGUS USER))) TRUE abc) [PRNTUTIL1] Unable to find deftemplate 'BOGUS' in function 'do-for-all-facts'. [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (do-for-all-facts ((?b (create$ USER 34))) TRUE abc) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (do-for-all-facts ((?b MALE)) TRUE (bind ?b 1)) [FACTQPSR3] Cannot rebind fact-set member variable b in function do-for-all-facts. CLIPS> (delayed-do-for-all-facts) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (delayed-do-for-all-facts TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (delayed-do-for-all-facts ()) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (delayed-do-for-all-facts (?B OBJECT) TRUE) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (delayed-do-for-all-facts ((?b A))) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function. CLIPS> (delayed-do-for-all-facts ((?b BOGUS)) TRUE) [PRNTUTIL1] Unable to find deftemplate 'BOGUS'. CLIPS> (delayed-do-for-all-facts ((?b A)) (progn (bind ?b 1) TRUE)) [FACTQPSR2] Binds are not allowed in fact-set query in function delayed-do-for-all-facts. CLIPS> (delayed-do-for-all-facts ((?b 34)) TRUE abc) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (delayed-do-for-all-facts ((?b (create$ BOGUS USER))) TRUE abc) [PRNTUTIL1] Unable to find deftemplate 'BOGUS' in function 'delayed-do-for-all-facts'. [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (delayed-do-for-all-facts ((?b (create$ USER 34))) TRUE abc) [PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query class restrictions. FALSE CLIPS> (delayed-do-for-all-facts ((?b MALE)) TRUE (bind ?b 1)) [FACTQPSR3] Cannot rebind fact-set member variable b in function delayed-do-for-all-facts. CLIPS> (assert (V (name [v]))) CLIPS> (assert (W (name [w]))) CLIPS> (assert (X (name [x]))) CLIPS> (assert (Y (name [y]))) CLIPS> (assert (Z (name [z])))) CLIPS> (do-for-all-facts ((?ins1 ?*list* X (create$ Y Z)) (?ins2 X (create$ Y Z) ?*list*)) TRUE (printout t ?ins1:name " " ?ins2:name crlf)) [v] [x] [v] [y] [v] [z] [v] [v] [v] [w] [w] [x] [w] [y] [w] [z] [w] [v] [w] [w] [x] [x] [x] [y] [x] [z] [x] [v] [x] [w] [y] [x] [y] [y] [y] [z] [y] [v] [y] [w] [z] [x] [z] [y] [z] [z] [z] [v] [z] [w] CLIPS> (assert (factoid)) CLIPS> (while TRUE do (delayed-do-for-all-facts ((?b factoid)) TRUE (progn (printout t DELAYED ?b crlf) (break))) (do-for-all-facts ((?b factoid)) TRUE (progn (printout t DO-FOR-ALL ?b crlf) (break))) (break)) DELAYED DO-FOR-ALL FALSE CLIPS> (deffunction quoxnar () (do-for-all-facts ((?b factoid)) TRUE (progn (printout t INS-RETURN ?b crlf) (return)))) CLIPS> (quoxnar) INS-RETURN CLIPS> (clear) CLIPS> (deftemplate point (slot x) (slot y)) CLIPS> (deffacts points (point (x 1) (y 2)) (point (x 3) (y 4))) CLIPS> (reset) CLIPS> (do-for-all-facts ((?f point)) TRUE (retract ?f) (+ ?f:x ?f:y)) [PRNTUTIL12] The variable/slot reference ?f:x cannot be resolved because the referenced fact f-1 has been retracted. [ARGACCES2] Function '+' expected argument #1 to be of type integer or float. FALSE CLIPS> (reset) CLIPS> (do-for-all-facts ((?f point)) TRUE (+ ?f:x ?f:z)) [PRNTUTIL13] The variable/slot reference ?f:z is invalid because the referenced fact f-1 does not contain the specified slot. [ARGACCES2] Function '+' expected argument #2 to be of type integer or float. FALSE CLIPS> (do-for-all-facts ((?f point)) TRUE (+ ?f:x ?f:78)) [PRNTUTIL14] The variable/slot reference ?f:78 is invalid because slot names must be symbols. CLIPS> (clear) CLIPS> (deftemplate a (slot x)) CLIPS> (deftemplate b (slot y)) CLIPS> (deftemplate c (slot z)) CLIPS> (deffacts init (a (x 1)) (a (x 2)) (b (y 3)) (b (y 4)) (c (z 5)) (c (z 6)) (c (z 7))) CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf)) 1 3 5 1 3 6 1 3 7 1 4 5 1 4 6 1 4 7 2 3 5 2 3 6 2 3 7 2 4 5 2 4 6 2 4 7 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?a)) 1 3 5 2 3 5 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?b)) 1 3 5 1 4 5 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?c)) 1 3 5 1 3 6 1 3 7 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?a ?b)) 1 3 5 2 4 5 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?b ?c)) 1 3 5 1 4 6 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?a ?c)) 1 3 5 2 3 6 CLIPS> (reset) CLIPS> (do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?a ?b ?c)) 1 3 5 2 4 6 CLIPS> (reset) CLIPS> (delayed-do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf)) 1 3 5 1 3 6 1 3 7 1 4 5 1 4 6 1 4 7 2 3 5 2 3 6 2 3 7 2 4 5 2 4 6 2 4 7 CLIPS> (reset) CLIPS> (delayed-do-for-all-facts ((?a a) (?b b) (?c c)) TRUE (printout t (if (fact-existp ?a) then ?a:x else "?") " " (if (fact-existp ?b) then ?b:y else "?") " " (if (fact-existp ?c) then ?c:z else "?") crlf) (retract ?a ?b ?c)) 1 3 5 2 4 6 CLIPS> (reset) CLIPS> (find-all-facts ((?a a) (?b b) (?c c)) (progn (retract ?a ?b ?c) FALSE)) () CLIPS> (facts) f-7 (c (z 7)) For a total of 1 fact. CLIPS> (reset) CLIPS> (find-fact ((?a a) (?b b) (?c c)) (progn (retract ?a ?b ?c) FALSE)) () CLIPS> (facts) f-7 (c (z 7)) For a total of 1 fact. CLIPS> (reset) CLIPS> (find-all-facts ((?a a) (?b b) (?c c)) (progn (if (eq ?b:y 3) then (retract ?b)) FALSE)) () CLIPS> (facts) f-1 (a (x 1)) f-2 (a (x 2)) f-4 (b (y 4)) f-5 (c (z 5)) f-6 (c (z 6)) f-7 (c (z 7)) For a total of 6 facts. CLIPS> (reset) CLIPS> (find-fact ((?a a) (?b b) (?c c)) (progn (if (eq ?b:y 3) then (retract ?b)) FALSE)) () CLIPS> (facts) f-1 (a (x 1)) f-2 (a (x 2)) f-4 (b (y 4)) f-5 (c (z 5)) f-6 (c (z 6)) f-7 (c (z 7)) For a total of 6 facts. CLIPS> (reset) CLIPS> (find-all-facts ((?a a) (?b b) (?c c)) (progn (if (eq ?b:y 3) then (retract ?b)) (if (eq ?c:z 5) then (retract ?c)) (if (eq ?a:x 2) then TRUE else FALSE))) ( ) CLIPS> (facts) f-1 (a (x 1)) f-2 (a (x 2)) f-4 (b (y 4)) f-6 (c (z 6)) f-7 (c (z 7)) For a total of 5 facts. CLIPS> (reset) CLIPS> (find-fact ((?a a) (?b b) (?c c)) (progn (if (eq ?b:y 3) then (retract ?b)) (if (eq ?c:z 5) then (retract ?c)) (if (eq ?a:x 2) then TRUE else FALSE))) ( ) CLIPS> (facts) f-1 (a (x 1)) f-2 (a (x 2)) f-4 (b (y 4)) f-6 (c (z 6)) f-7 (c (z 7)) For a total of 5 facts. CLIPS> (clear) CLIPS> (watch facts) CLIPS> (deftemplate foo (multislot list)) CLIPS> (assert (foo (list 1 2))) ==> f-1 (foo (list 1 2)) CLIPS> (do-for-fact ((?f foo)) TRUE (retract ?f) (bind ?x ?f:list) (assert (foo (list ?x 3)))) <== f-1 (foo (list 1 2)) [PRNTUTIL12] The variable/slot reference ?f:list cannot be resolved because the referenced fact f-1 has been retracted. FALSE CLIPS> (assert (foo (list 3 4)) (foo (list 5 6))) ==> f-2 (foo (list 3 4)) ==> f-3 (foo (list 5 6)) CLIPS> (do-for-all-facts ((?f foo)) TRUE (retract ?f) (bind ?x ?f:list) (assert (foo (list ?x 3)))) <== f-2 (foo (list 3 4)) [PRNTUTIL12] The variable/slot reference ?f:list cannot be resolved because the referenced fact f-2 has been retracted. FALSE CLIPS> (unwatch facts) CLIPS> (clear) CLIPS> (dribble-off)