Re: JESS: LHS, lists and productions.

2007-09-07 Thread michaeljsmith
; Bob Kirby Praise be the heady power of declarative programming! - Mike Smith --- Begin Message --- Title: Re: JESS: LHS, lists and productions. Thanks!  This is exactly what I need.  As you can see in my follow up email, I tried to do this transformation, but for some odd reason – I think i

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Dusan Sormaz
Ernest, is it overlook or allowed? I though that each independent variable has to have distinct name within a rule. Your fact ?t should be different from template ?t if templates in a multislot are symbols. Dusan Sormaz At 12:11 PM 9/7/2007, you wrote: Same idea: (defrule removeTransform

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Hal Hildebrand
Ah. Should have paid more attention to the details. This has been a tremendous help and my rules make much more sense and don't have that really ugly feel to them. Thanks! On 9/7/07 10:32 AM, "Ernest Friedman-Hill" <[EMAIL PROTECTED]> wrote: > > On Sep 7, 2007, at 1:01 PM, Hal Hildebrand wro

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Ernest Friedman-Hill
On Sep 7, 2007, at 1:01 PM, Hal Hildebrand wrote: I guess I'm more than a little confused as to the "(templates $? ?t $?)" syntax. Remember that the first time a variable is used, it matches whatever's there, and subsequent uses of that same variable match only whatever the first usage

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Hal Hildebrand
Thanks! This is exactly what I need. As you can see in my follow up email, I tried to do this transformation, but for some odd reason ­ I think it was my placement of (watch all) - I didn¹t see all the assertions. However, I still have the endless loop issue if I combine this with the removeTran

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Hal Hildebrand
I guess I'm more than a little confused as to the "(templates $? ?t $?)" syntax. I would have expected that I could have rewritten the rule Wolfgang provided to: (defrule makeTransforms ?s <- (source (id ?id) (templates $? ?template $?)) (not (transform (source ?id))) => (assert (

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Robert Kirby
This can all be combined in a single rule without a "foreach" loop. (defrule manage-source-templates "Logically assert or retract templates for source" (logical (source (id ?id) (templates $? ?template $?))) (not (transform (source ?id) (template ?template))) => (assert (transf

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Ernest Friedman-Hill
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

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Hal Hildebrand
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,

Re: JESS: LHS, lists and productions.

2007-09-07 Thread Wolfgang Laun
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 ?tem

JESS: LHS, lists and productions.

2007-09-07 Thread Hal Hildebrand
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