Same idea:
(defrule removeTransforms
?t <- (transform (source ?id) (template ?t))
(not (source (id ?id)(templates $? ?t $?))
=>
(retract ?t))
On Sep 7, 2007, at 11:57 AM, Hal Hildebrand wrote:
Doh! That does work well and I'll certainly replace my cheesy
solution with
this, but one of the issues I'm dealing with is that the set of
templates
can change and I would like to ensure that as changes to the list of
templates occur, the corresponding transforms are asserted or
retracted.
Sorry, this is an additional constraint I would like to satisfy that I
should have noted.
On 9/7/07 8:28 AM, "Wolfgang Laun" <[EMAIL PROTECTED]>
wrote:
Assuming that the absence of any "transform" fact with a "source"
slot
equal to the "id" slot of a new "source" fact is the criterion for
creating the "transform" facts:
(defrule makeTransforms
?s <- (source (id ?id)(templates $?templates))
(not (transform (source ?id)))
=>
(foreach ?temp $?templates
(assert (transform (source ?id) (template ?temp))))
)
kr
Wolfgang
Hal Hildebrand wrote:
I have a system where I need to ensure that for every member of a
list,
there is a fact which contains that member. For example, here's
my domain:
(deftemplate source (slot id) (multislot templates))
(deftemplate transform (slot source) (slot template))
What I would like is to write some rules that ensure that for
ever member of
the templates slot of a "source", I have a corresponding
transform. If I
assert:
(assert source (id 1) (templates (create$ a b c)))
I would like to see three facts asserted in response:
(assert transform (source 1) (template a))
(assert transform (source 1) (template b))
(assert transform (source 1) (template c))
I have accomplished this by creating an intermediary fact and
some rules
which essentially cycle through the list of templates in the source,
asserting a transform for each. However, this just feels wrong.
It seems
like I should be able to express this without the intermediary
facts.
Perhaps this is where backward chaining would be useful? Or
perhaps I can
use the new "accumulate" CE? Or, have I already found the
solution using an
intermediary fact to cycle through the list of templates?
Any help/suggestions would be appreciated.
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------