Jess71p2 40 - TRUE Jess>(reset => f-0(MAIN:initial-fact...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
6. Making Your Own Rules 32 TRUE Jess> (reset) ==> f-0 (MAIN::initial-fact) TRUE Jess> (defrule welcome-toddlers "Give a special greeting to young children" (person {age < 3}) => (printout t "Hello, little one!" crlf)) welcome-toddlers: +1+1+1+t TRUE Jess> (assert (person (age 2))) ==> f-1 (MAIN::person (firstName nil) (lastName nil) (age 2)) ==> Activation: MAIN::welcome-toddlers : f-1 <Fact-1> Some of these diagnostics are interesting. We see first of all how issuing the reset command asserts the fact (initial-fact) . You should always issue a reset command when working with rules. When the rule itself is entered, we see the line "+1+1+t". This tells you something about how the rule is interpreted by Jess internally (see The Rete Algorithm for more information.) When the fact (person (age 2)) is asserted, we see the diagnostic "Activation: MAIN::welcome- toddlers : f-1". This means that Jess has noticed that the rule welcome-toddlers has all of its LHS conditions met by the given list of facts ("f-1"). After all this, our rule didn't fire; why not? Jess rules only fire while the rule engine is running
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online