I think Chris Schneider wrote:
> 
> JESS Gang,
> 
> We just started fooling around with JESS, and have the following
> questions/comments:

I'll answer some of these:

> 
> 1) Why must all "list" facts be ordered?  It would be nice to assert
> something like (shopping-list bread milk paper-towels), and then have this
> fact match a (shopping-list milk bread paper-towels) pattern in some rule.
> I guess you have to use a multislot in a deftemplate to implement a true
> set, but you still have to do some pretty scary stuff in your pattern
> matching.

This is a reasonable question - the answer is efficiency. Jess can
check specific positions in an ordered fact in time N, where N is the
number of items. Checking them in any permutation would require at
least time N! (N factorial) (but this would require lots of memory - a
less storage-intensive method would work in time N^2) Often the order
conveys meaning.

You could write a deffunction or userfunction called
contains-in-some-order to be used like this:

(defrule example-1
        (shopping-list $?groceries)
        (test (contains-in-some-order $?groceries milk bread paper-towels))
        =>      
        ...

which isn't too onerous, I think. You can implement
contains-in-some-order using whatever algorithm makes the most sense
for your application.

> 
> 2) Is there any way to do an "un-deffacts" (retract-deffacts?) whose effect
> will persist across a (reset)?
> 

There is no undeffacts command, but one could easily be added - I'll
make a note of it for the next release.

> 3) Can anyone shed more light on the Boolean console parm in
> rete.addInputRouter()?  The description in the JESS manual confused me.
> 

In both CLIPS and Jess, the (read) command works differently depending
on whether it's reading from a file or from the console. If (read t) is
called and you type 

A B C

the function will return 'A'. If (read t) is called again, you have
to type some more: B C '\n' are lost forever.

On the other hand, if you open a file FOO and call (read FOO), and the
file contains the same line, the first call will return A, the second
B, the third C. If you call read a fourth time, the first token of the
next line is returned. On the other hand, if you call readline instead
of the fourth read, a blank line is returned: the end of the line has
not yet been consumed.

Basically, a console-like stream consumes an entire line at a time,
even if only one token is requested; a file-like stream consumes only
the characters that are needed to fulfil the request.

> 4) Is there any way to create "record structured" variables whose values
> will persist across a (reset)?  I need something that a) has slots like a
> deftemplate, b) will let me change the slot values, and c) will maintain
> those changes across (reset) calls.  I'd like to avoid resorting to
> defclass/definstance, but that seems like the only way to do this.


Well, you can use the Bag functions, which are a simple interface to
hash-table like structures; or you can call (set-reset-globals nil)
and have a defglobal point to a multifield.


> 5) Apparently, I can't use an expression with the test function.  For example,
> the following is legal:
> 
> (defrule works
>       (test (> 2 1))
>       =>
>       (assert (this works)))
> 
> However, the following is illegal:
> 
> (defrule fails
>       (test (and (> 2 1) (> 3 2)))
>       =>
>       (assert (this fails)))
> 

If I put these both in a file, followed by (watch all) (reset) and
(run), I see both rules fire and both facts asserted. This is with
Jess 4.1 final. Do you see something different? Note that if a (test)
CE is the first CE on the LHS of a rule, the rule will not fire
without a (reset) being issued (same as CLIPS.)

> 
> 
> Thanks for the help!
> 
> - Chris
> 
> ------------------------------------
> Chris Schneider
> ThinkerTools Research Group
> http://thinkertools.berkeley.edu/tt/
> [EMAIL PROTECTED]
> (510) 873-8125
> ------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (510) 294-2154
Sandia National Labs                FAX:   (510) 294-2234
Org. 8920, MS 9214                  [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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to