JESS: multiple bindings of a multislot

2011-08-15 Thread Wolfgang Laun
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


RE: JESS: multiple bindings of a multislot

2011-08-15 Thread Friedman-Hill, Ernest
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.