On 18/02/2013, pdario <dario.piantanida(a)gmail.com> wrote:
laune wrote
> There is always just one fit; it just seems that there are multiple
> fits - when you define your individual cases sloppily.
Well, this is an assumption to get a completely disjointed classification,
but this is not my case.
I have a first level discount if you pay online and a second level discount
if you pay online AND buy a special product.
So, the second is true only if the first is.
Not *quite* correct: you have 1st level discount if you pay online and
DO NOT buy a special product.
laune wrote
>> when
>> Cart ($items : buyingItems, payment == Card....)
>> i : Item (code == XXXXX) from $items
>> then
>
> I don't see why "XXXXX" shouldn't come from a parameter fact.
>
> As a general strategy, I try to avoid the "on-the-fly" objects
> available with "from" and prefer these subordinate items to be
> properly inserted facts. Usually this simplifies writing rules.
If I simply put several carts and the whole items form them into memory, it
would create a mess of carts and items, won't it?
What will keep each item with its own cart?
a) Add a reference to its cart to each item.
b) Add facts CartItem( Cart cart, Item item)
c) Use the contains operator to establish an Item being part of a
cart's item list
-W