No I don't think there has been much discussion in it in Drools 3 (but feel free to start one ! thats what this list is for).
But on the topic of what you want: you want some "calculation" to be performed once, and the results of that calculation used in subsequent rules. This is a reasonably common thing. What I would suggest trying is to create an object specifically to hold the results of that "calculation" (which is just pulling things out of a list). You can then bootstrap that calculation by having a rule with higher salience take the ShoppingList, extract the vitamins, and assert them to the rule engine as a seperate object (VitaminList??). You can then have other rules depend on that vitamin list being there. That way all the rules that depend on vitamin list will be able to be checked, yet the list is only calculated once (which will always happen first). Further down the track you may have a rule that changes that vitamin list, thus requiring the rules to be evaluated again, so its not a bad approach to try. Michael. --------------------------------------------- > Hello Michael > > We have an Object "ShoppingList" that contains a List of "Vegetables" > Each "Vegetable" has a "vitamin" attribute that stores the types of > vitamins the > vegetable contains. > > The Rule is to be applied on the "ShoppingList" -- The vegetables in the > list > should contain all the vitamins for a balanced diet. In case of > deficiency > suggest appropriate vegetables to fulfill the deficiency. > > Even though we can handle this rule in many ways, it would be better if we > can > write a function to find out all the vitamins that are contained in the > list of > vegetables chosen, as soon as the rule is invoked. Then apply that result > to the > set of rules. > > If we are to invoke a function for computation at each rule, then it will > degrade performance. A function that does initialization would be of great > use > in such cases. > > Please advise on the strategy that can be adopted in such cases. > > You did mention about an "else" condition being made available in Drools > 3. > Please let me know of the new syntax that might be used for the same. Also > how > do we know which condition failed that resulted in the firing of the else > condition. > > Thanks and Regards > Jayaram C S > >
