On Mon, 9 Aug 1999, Ernest Friedman-Hill wrote:

> This is a very frequently asked question (I supposed it should be a
> FAQ entry) by folks just getting started in rule-based languages. The
> reason the solution isn't obvious is because you're thinking about it
> in procedural-programming terms, which isn't appropriate for a
> rule-based language. Instead of trying to create a list of facts with
> some property and then iterating over the list, you should write a
> rule which operates on one fact based on some criteria.
> 
> (defrule init
>   =>
>   (store HELPER (new Helper)))
> 
> (defrule one-fact
>   (f (v ?x))   
>   =>
>   (call (fetch HELPER) addSlotVValue ?x))
>  )
> 
> Instead of using a custom "Helper" object for this, you might use the
> Jess "bag" function, which is really just a Jess language interface to
> java.util.Hashtable. 

I thought about approach you've proposed. It will work if I need this rule
fired only once. What if I need it to be fired several times? I need
helper to be initialized before first fact added, and some method of it
fired after last fact added to it. In my case Helper is not just
container, it is doing some processing.

Sincerely,
Vadim

-- 
;;-----------------------------------+-----------------------------------+
;; [EMAIL PROTECTED]      + Those who do not understand Unix  +
;; Project Manager, Matranet Inc.    + are condemned to reinvent it,     +
;; http://www.matranet.com/          + poorly.          (H. Spencer)     +
;;-----------------------------------+-----------------------------------+

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