Thanks.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Jason Morris
Sent: Thursday, January 19, 2006 4:32 PM
To: jess-users@sandia.gov
Subject: Re: JESS: Naming facts


On 1/19/06, Donnelly <[EMAIL PROTECTED]> wrote:
> Given a list of device names, when a device is out of limits I want to
> assert an appropriately named fact
>   devicename-exceeds-limits.
> If I use (assert (sym-cat ?device ?condition))  the fact becomes
>  sym-cat devicename -exceeds-limits.
> How can I create correctly named facts?

Hi Stephen,

I haven't contributed much lately, so I thought that I'd try this one.
See if this works for you...

;; Init
(clear)
(watch all)
(import java.util.HashMap)
(bind ?devices (new HashMap))
(?devices put "widget-1" "EXCELLENT")
(?devices put "do-jigger" "NOMINAL")
(?devices put "widget-2" "FAILED")
(?devices put "widget-3" "NOMINAL")
(?devices put "thingy-1" "GOOD")
(?devices put "thingy-2" "FAILED")

;; Functions
(deffunction assert-out-of-limits-facts (?device-map)
    (foreach ?name (?device-map keySet)
    (if (eq (?device-map get ?name) "FAILED") then
        (bind ?fact (str-cat "(assert (" ?name "-exceeds-limits))"))
        (eval ?fact))))

;; Program
(assert-out-of-limits-facts ?devices)

;; OUTPUT
;Jess, the Rule Engine for the Java Platform
;Copyright (C) 2005 Sandia Corporation
;Jess Version 7.0b5 1/5/2006
;
; ==> f-0 (MAIN::thingy-2-exceeds-limits)
; ==> f-1 (MAIN::widget-2-exceeds-limits)

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

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