ordered facts in do-for-all-facts?

271 views
Skip to first unread message

denis.be...@gmail.com

unread,
Jan 3, 2021, 3:24:16 AM1/3/21
to CLIPSESG
Is there any way of applying function "do-for-all-facts" and similar ones to ordered facts?

The Basic user manual says:
"3.4 Implied Deftemplates
Asserting or referring to an ordered fact (such as in a LHS pattern) creates an “implied” deftemplate with a single implied multifield slot. The implied multifield slot’s name is not printed when the fact is printed. The implied deftemplate can be manipulated and examined identically to any user defined deftemplate (although it has no pretty print form)."


What is this implied multifield slot name?
Can it be used (and how) in functions such as "do-for-all-facts" and can it be used reliably (i.e. not only as something undocumented and possibly deprecated in the future)?
I couldn't find anything about it in the documentation.

Example: suppose the facts base has facts such as (foo a b)
I tried haphazardly:
(do-for-all-facts
((?f foo))
(eq (nth$ 2 ?f:1) a)
(retract ?f)
)

but I get the expected message saying that 1 (in ?f:1) is not a symbol.

CLIPS Support

unread,
Jan 4, 2021, 1:47:03 PM1/4/21
to CLIPSESG
Use implied for the slot name. It is mentioned in the documentation for the fact-slot-names and fact-slot-values functions. I will update the documentation to include it in sections 3.4 as well.

         CLIPS (6.31 6/12/19)
CLIPS> 
(assert (foo b a)
        (foo 1 2 3)
        (foo b c d)
        (foo e a f g h)
)
<Fact-4>
CLIPS> 
(do-for-all-facts
((?f foo))
(eq (nth$ 2 ?f:implied) a)
(retract ?f)
)
CLIPS> (facts)
f-0     (initial-fact)
f-2     (foo 1 2 3)
f-3     (foo b c d)
For a total of 3 facts.
CLIPS> 



Reply all
Reply to author
Forward
0 new messages