RE: JESS: multiple bindings of a multislot
Probably. The specialized Rete network nodes are faster than general function calls, as they have less overhead and work directly in Java. From: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] On Behalf Of Wolfgang Laun Sent: Monday, August 15, 2011 11:22 AM To: jess-users Subject: Re: JESS: multiple bindings of a multislot I solved it by binding the lot: (Temp (m $?mels)) and writing deffunctions testing all other patterns. I ran into this while trying to solve the Zebra Puzzle in a way fundamentally different from the example distributed with Jess. I have all permutations as facts and select them by filtering according to the puzzle's givens. This is where things like ($? ivory green $?) or (? ? milk ? ?) would have to be written in addition to the binding of the entire quintuple
Re: JESS: multiple bindings of a multislot
I solved it by binding the lot: (Temp (m $?mels)) and writing deffunctions testing all other patterns. I ran into this while trying to solve the Zebra Puzzle in a way fundamentally different from the example distributed with Jess. I have all permutations as facts and select them by filtering according to the puzzle's givens. This is where things like ($? ivory green $?) or (? ? milk ? ?) would have to be written in addition to the binding of the entire quintuple. Currently I'm not sure whether the use of those deffunction tests is the reason my solution is considerably slower than the distributed one. Cheers Wolfgang On 15 August 2011 16:53, Friedman-Hill, Ernest wrote: > Yes, "reopening" a slot like this is an error; this behavior was inherited > from CLIPS. > > I can't think of any particularly elegant workarounds. You can name those > anonymous multifields and refer to them later in the rule, though -- i.e., > > (Temp (m $?first one two $?rest) > > "?first" and "?rest" can be used elsewhere in the same rule to refer to > what came before and after "one two". > > > >From: owner-jess-us...@sandia.gov [mailto: > owner-jess-us...@sandia.gov] On Behalf Of Wolfgang Laun >Sent: Sunday, August 14, 2011 2:30 PM >To: jess-users >Subject: JESS: multiple bindings of a multislot > > >Given > (deftemplate Temp (multislot m)) >Cursory tests seem to indicate that a Temp pattern may be written > with just a single set of clusters consisting of '?', '$?' and their named > cousins. As an example, it's possible to write > (Temp (m $? one two $?)) >but not > (Temp (m $? one two $?)(m $?mvals)) >to ascertain that "one" and "two" occur as indicated and to bind > ?mvals to the entire list. > >There is, of course, the workaround to use (Temp) once more, making > sure that the facts are the same, but this is rather a lot to write for a > relatively simple thing. > >Is it correct that one (multi)slot cannot be used more than once in > a single pattern (except as a variable between braces)? > >-W > > > > > > > To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' > in the BODY of a message to majord...@sandia.gov, NOT to the list > (use your own address!) List problems? Notify owner-jess-us...@sandia.gov. > > >
RE: JESS: multiple bindings of a multislot
Yes, "reopening" a slot like this is an error; this behavior was inherited from CLIPS. I can't think of any particularly elegant workarounds. You can name those anonymous multifields and refer to them later in the rule, though -- i.e., (Temp (m $?first one two $?rest) "?first" and "?rest" can be used elsewhere in the same rule to refer to what came before and after "one two". From: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] On Behalf Of Wolfgang Laun Sent: Sunday, August 14, 2011 2:30 PM To: jess-users Subject: JESS: multiple bindings of a multislot Given (deftemplate Temp (multislot m)) Cursory tests seem to indicate that a Temp pattern may be written with just a single set of clusters consisting of '?', '$?' and their named cousins. As an example, it's possible to write (Temp (m $? one two $?)) but not (Temp (m $? one two $?)(m $?mvals)) to ascertain that "one" and "two" occur as indicated and to bind ?mvals to the entire list. There is, of course, the workaround to use (Temp) once more, making sure that the facts are the same, but this is rather a lot to write for a relatively simple thing. Is it correct that one (multi)slot cannot be used more than once in a single pattern (except as a variable between braces)? -W To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.