I think [EMAIL PROTECTED] wrote:

> 
> ;(deftemplate offer
> ; (slot mark
> ;  (type STRING)
> ;  (default " "))
> ; (slot course
> ;  (type INTEGER)
> ;  (default " "))

Note that, as the manual explains, the "type" qualifier is ignored;
and furthermore, if you're going to use a slot default, it's a good
idea to make it representative of the data you will store in the slot;
doing otherwise will give rise to type errors (so the INTEGER slot's
default should be 0, I'd think.)

> (defrule choose-car
>  (offer(mark ?m) (course ?c) (age ?a) (price ?p) (colour ?c))
>  (<= ?a 3)
>  (printout t ?m crlf))


Three major errors in this rule. First, the things on the LHS of a rule
are patterns to match, not function calls; see
http://herzberg.ca.sandia.gov/jess/FAQ.shtml#Q15 . Second, there needs
to be a "=>" arrow between the left and right sides of the
rule. Third, you used the same variable ?c to match both the colour
and course slots; in the Jess pattern language, this means that both
those slots must contain the same value, which I don't think is what
you mean. So the rule should look like

 (defrule choose-car
  (offer (mark ?m) (course ?s) (age ?a&:(<= ?a 3)) (price ?p) (colour ?c))
  =>
  (printout t ?m crlf))

Note also that you don't need to match every slot with a variable if
you're not going to use the values; it just slows things down a little.



> (deffacts offer
>  (mark VW_Golf) (course 125000) (age 3) (price 4400) (colour red))
...
>  ((mark Mazda) (course 105000) (age 9) (price 5000) (colour red)))

A "deffacts" is a group of facts, with its own name; you've omitted
the opening parenthesis of the first fact, so this looks like a bunch
of ordered facts with single datums, rather than an unordered "offer"
fact. You want something like

 (deffacts my-list-of-offers
  (offer (mark VW_Golf) (course 125000) (age 3) (price 4400) (colour red))
  (offer (mark Mazda) (course 105000) (age 9) (price 5000) (colour red)))
> 
> I've got another question: how to pick up from offer these one which are
> named, for example:
> "VW Golf" (the space between "VW" and "Golf), i mean how JESS can
> distinguish it in facts?

Symbols (unquoted) and Strings (double-quoted) are two separate data
types. If you need a slot to contain characters with spaces, then just
use double-quoted Strings everywhere in that slot. Make sure you're
consistent, because as I said, they're two separate types and Ford and
"Ford" don't match.


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