I think Eric W. Bonnett wrote:
>       Hmm, I don't think so. Copy\paste! :) I should have mentioned it
> before, I'm using the publicly available version 6.1p4 that I downloaded
> based on instructions in the book.

On the off chance that there was something about this version, I tried
it myself -- but it worked fine. Here's the program I ran:

(deftemplate SomethingIWant "Stuff I want"
    (slot Name (default Whatever) )
    (slot Price (default 10) )
    (slot Priority (default 0) )
    (slot Selected (default false) )
)

(defrule items-to-buy
  ?ItemFound <- (SomethingIWant   (Name ?ItemName)
                                  (Price ?ItemPrice)
                                  (Priority ?ItemPriority1)
                                  (Selected false ) )
  (not (SomethingIWant (Selected false) (Priority ?p&:(< ?p ?ItemPriority1))))
  =>
  (printout t  "Found: " ?ItemName ", " ?ItemPrice ", " ?ItemPriority1 crlf)
  (modify ?ItemFound (Selected true) )
  )

(assert
    (SomethingIWant
        (Name "TiVo")
        (Price 200)
        (Priority 1)
    )
)

(assert
    (SomethingIWant
        (Name "Tires")
        (Price 800)
        (Priority 1)
    )
)

(assert
    (SomethingIWant
        (Name "Carb")
        (Price 400)
        (Priority 1)
    )
)

(assert
    (SomethingIWant
        (Name "DVD Burner")
        (Price 400)
        (Priority 5)
    )
)

(assert
    (SomethingIWant
        (Name "Wheels")
        (Price 1000)
        (Priority 2)
    )
)

(assert
    (SomethingIWant
        (Name "shocks")
        (Price 900)
        (Priority 2)
    )
)

(run)

And here's the output:

Found: Carb, 400, 1
Found: Tires, 800, 1
Found: TiVo, 200, 1
Found: shocks, 900, 2
Found: Wheels, 1000, 2
Found: DVD Burner, 400, 5

---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          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