JessLanguage

Lists
	(+ 3 2)  (a b c)

Functions Variables
	(bind ?x "The value")
	(bind $?grocery-list (create$ eggs bread milk))

Deffunctions
	(deffunction max (?a ?b)
	(if (> ?a ?b) then
		(return ?a)
	else
	  (return ?b)))

Facts
	(temperature 98.6)
	(deftemplate automobile
		"A specific car."
		(slot make)
		(slot model)
		(slot year)
		(slot color (default white)))

Defclasses
	(defclass pump jess.examples.pumps.Pump)

IF public class Pump { public String getName() { ... } public int getFlow() { ... } public void setFlow(int f) { ... } } THEN RESULT IS ... (deftemplate pump "$JAVA-OBJECT$ jess.examples.pumps.Pump" (slot class) (slot name) (slot flow) (slot OBJECT))

Deffacts
	(deffacts automobiles
	(automobile (make Chrysler) (model Le Baron) (year 1997))
	(automobile (make Ford) (model Contour) (year 1996))
	(automobile (make Nash) (model Rambler) (year 1948)))

Defrules
	(defrule example-1
	 "Announce 'a b c' facts"
	 (a b c)
	 =>
	  (printout t "Saw 'a b c'!" crlf))
	Jess> (clear)
	TRUE
	Jess> (watch all)
	TRUE
	Jess> (defrule example-1
		"Announce 'a b c' facts"
		(a b c)
		=>
		(printout t "Saw 'a b c'!" crlf))
	example-1: +1+1+1+1+t
	TRUE
	Jess> (assert (a b c))
	 ==> Activation: example-1 : f-0
	 ==> (a b c)
	 <Fact-0>
	Jess>  (run)
	FIRE [Defrule: example-1 "Announce 'a b c' facts";
    1. patterns; salience: 0] f-0
Saw 'a b c'! TRUE Jess>
	(defrule example-5
	?fact <- (command "retract me")
	=>
	(retract ?fact))
	(declare (salience -100))


		[ReteExample | JessAndAgents | JessAndJava]

(last edited September 30, 2009)
Find Page by browsing or searching