Jess71p2 29 - (year 1997) (color white)) For a total of 2...

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

View Full Document Right Arrow Icon
5. Working Memory 21 5.2. Unordered facts In object-oriented languages like Java, objects have named fields in which data appears. Unordered facts offer this capability (although the fields are traditionally called slots. ) (automobile (make Ford) (model Explorer) (year 1999)) Before you can create unordered facts, you have to define the slots they have using the deftemplate construct. As an example, defining the following template: Jess> (deftemplate automobile "A specific car." (slot make) (slot model) (slot year (type INTEGER)) (slot color (default white))) would allow you to define the fact shown here. Jess> (reset) Jess> (assert (automobile (model LeBaron) (make Chrysler) (year 1997))) <Fact-1> Jess> (facts) f-0 (MAIN::initial-fact) f-1 (MAIN::automobile (make Chrysler) (model LeBaron)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (year 1997) (color white)) For a total of 2 facts in module MAIN. Note that the car is white by default. If you don't supply a default value for a slot, and then don't supply a value when a fact is asserted, the special value nil is used. Also note that any number of additional automobiles could also be simultaneously asserted onto the fact list using this template. Note also that we can specify the slots of an unordered fact in any order (hence the name.) Jess rearranges our inputs into a canonical order so that they're always the same. As you can see above, each fact is assigned an integer index (the fact-id ) when it is asserted. You can remove an individual fact from the working memory using the retract function. Jess&gt; (retract 1) TRUE...
View Full Document

This note was uploaded on 03/02/2010 for the course COMP 102 taught by Professor Smith during the Spring '10 term at California State University , Monterey Bay.

Ask a homework question - tutors are online