In a December 2004 reply posted on the forum, we see the script dan.clp (below). We have observed that its pattern
   (foo (data $?data&:(= (length$ $?data) 0)))

can be rewritten more simply

   (foo (data ))

and the rule behaves similarly (cf. also the fact printouts in the watch messages). However, in Jess v7.0b4, ppdefrule omits the "(data )" pattern from its output. Is our simpler syntax for testing multislots unsupported? Many thanks,

Jonathan Sewall
_____________________

;;================ dan.clp ====================
(clear)
(watch all)

(deftemplate foo
(slot id)
(multislot data))

(defrule delete-empty-foos
"Retracts all foo facts with no data"
?f <- (foo (data $?data&:(= (length$ $?data) 0)))
=>
(retract ?f))

(reset)
(assert (foo (id abc123)))
(run)

;;=================== New: now revise the rule ============
(undefrule delete-empty-foos)
(defrule delete-empty-foos
"Retracts all foo facts with no data: simpler"
?f <- (foo (data ))
=>
(retract ?f))

(reset)
(assert (foo (id anId)))
(agenda)
(run)
(ppdefrule delete-empty-foos)

If you run this combined batch file, Jess prints out:

MAIN::delete-empty-foos: +1+1+1+1+t
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::foo (id abc123) (data ))
==> Activation: MAIN::delete-empty-foos :  f-1
FIRE 1 MAIN::delete-empty-foos f-1
<== f-1 (MAIN::foo (id abc123) (data ))
<== Focus MAIN
MAIN::delete-empty-foos: +1+1+1+t
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::foo (id anId) (data ))
==> Activation: MAIN::delete-empty-foos :  f-1
[Activation: MAIN::delete-empty-foos  f-1 ; time=2 ; salience=0]
For a total of 1 activations in module MAIN.
FIRE 1 MAIN::delete-empty-foos f-1
<== f-1 (MAIN::foo (id anId) (data ))
<== Focus MAIN
"(defrule MAIN::delete-empty-foos \"Retracts all foo facts with no data: simpler\" ?f <- (MAIN::foo) => (retract ?f))"

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