JESS: empty list pattern and ppdefrule
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]
Re: JESS: empty list pattern and ppdefrule
I think Jonathan Sewall wrote: However, in Jess v7.0b4, ppdefrule omits the (data ) pattern from its output. Is our simpler syntax for testing multislots unsupported? Many thanks, Seems to work as ever; this is apparently just a bug in the pretty-printer. Thanks for the report. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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]
Re: JESS: empty list pattern and ppdefrule
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 )) Hi Jonathan, This is an interesting point...since it was also my code :-D Had I known then what I know now from studying Jess's implementation, that Ernest actually tests the length of multislots as a condition of the pattern matching process, I would have opted for your shorter code. At the time, it seemed logical enough. My contention is that shortcuts are great if you understand their mechanics, else they introduce an unknown liability in your code. Cheers, Jason - Morris Technical Solutions LLC www.morristechnicalsolutions.com [EMAIL PROTECTED] phone/fax: 503.692.1088 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]