I think Udo Dieckmann wrote:
> Ok, thanks, there's my decoder ring.  It got activated.  Can I try and
> explan what's going on with the rule in order to make sure I've got it 
> right?

[ explanation deleted ]

> 
> Is that about right?

Yes except that each line is a pattern itself; there are four patterns
on the LHS.

> 
> Definitely my error was in not understanding the patternization in
> (last-week-inventory ?lwi) etc.  I THINK I've got it now....
> It's almost like saying "LET any fact asserted as a last-week-inventory
> be known as ?lwi" ....


Yes, pretty much.

Note that since all of the facts  are intended to be unique -- i.e,
there's only ever going to be one last-week-sales fact -- then you
could write things using unordered facts with named slots. The
rules would be both more efficient and easier to read. You can
comment, too.

(deftemplate data (slot type) (slot last-week) (slot this-week))

(assert (data (type sales) (last-week 10) (this-week 20)))
(assert (data (type inventory) (last-week 23) (this-week 22)))

(defrule my-rule
  ;; Sales are increasing
  (data (type sales)
        (last-week ?slw) (this-week ?stw&:(< ?slw ?stw)))

  ;; Inventory decreasing
  (data (type inventory)
        (last-week ?ilw) (this-week ?itw&:(> ?ilw ?itw)))

  =>
  (evaluate-orders))



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

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