I think Ina Sollinger wrote:
[Charset Windows-1252 unsupported, filtering to ASCII...]
> Hi all,
> 
> i was wondering, if someone could give me an answer on the following 2
> questions:
> 1. is it possible to set up a qualifier on an element of a multivariable in
> the LHS of a rule?
>     i.e.: imagine iam having a mulitvariable $?example which contains
> (astring 0.5 0.8)
>     then iam having some rules which shall fire if the second element of the
> multivariable is <1
>     however, iam not sure how to write such an rule and if it works for an
> multivariable. my understanding in the convenience of multivariables so far
> was, that i can only test in the         LHS if the list of a multivariable
> contains a particular value...


Well, the basic idea is not to match the whole list with one
multifield. If you need to add qualifiers to specific items, then use
more than one variable -- i.e., 

        (somefact ?first ?n&:(< ?n 1) $?rest)

is a pattern that matches a somefact fact containing at least two data
items; the first one is matched by ?first, the second by ?n, which
must be less than 1, and all the rest beyond the first two (zero or
more) are matched by $?rest. 

> 
> 2. Also, iam still not sure if I would be better in using deftemplates
> instead of a multivariable.

If you've got a multislot that will always contain X items, and each
item has a specific meaning, it will always be more efficient to use
dedicated slots for each value.

> iam thinking that using a multivariable for my problem is more convenient
> when it comes to parse values from java to jess and from jess to java (for
> instance not calling fact-slot-value or store/ fetch several times).


Here you might do better showing us code to criticize. Note that
fact-slot-value is a rather specialized function, and only people
writing tools or doing some kind of metaprogramming should need to use
it. Often if you find you're needing it it's a sign you're approaching
things the wrong way.

Regarding store and fetch: they are NOT MAGIC. It's odd how many
people think these functions have some magical powers; they do
not. All you need to pass a value between Jess and Java is a known
location to leave the value, and that's all that store and fetch
provide. Store and fetch are a bit MORE complictaed to use than a
function you could write yourself, since fetch() on the Java side
returns a jess.Value object (because fetch has to handle any possible
kind of data.)

If you're writing Java code anyway, they create a function
"sendValuesFromJess()" which Jess can call to drop off all three
values at once, and a function "getValuesFromJava" that Jess can call
to retrieve three values at once -- whatever is convenient.


Hope this helps.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to