I think [EMAIL PROTECTED] wrote:

> 
> (defrule Function-Parameter-Required-Passed
>       "Check current Function Required Parameter"
>       (Input (name Function) (value ?functionName))
>       (Function (name ?functionName)(requiredParameter
> $?requiredParameterList))
> 
>       ;; 1. check for each parameter in the "requiredparameterList" there
> is an Fact
>       ;;    "Param" with matching "name" slot.
> 

OK, let's look at this. To match a Function and one corresponding
Param, you'd write

  (Function (requiredParameter $?before ?param $?after))
  (Param (name ?param))

"$?before" matches zero or more items in the list before the item of
interest, "?param" is the item of interest, and "$?after" matches zero
or more items after the item of interest.

Now, to match the case where there's a parameter in the list and
there's no Param fact, we'd say:

  (Function (requiredParameter $?before ?param $?after))
  (not (Param (name ?param)))

Now, this will match once for each non-existent Param. What we want is
something that will match if there are no non-existent Param facts; so
we just put "not" around this whole thing (we need an "and" to group
them first:)

  (not (and (Function (requiredParameter $?before ?param $?after))
            (not (Param (name ?param)))))

Which you could read as "It's not the case that there's a ?param in
this Function with no corresponding ?param fact."

Note that this will also match if there's no appropriate "Function"
fact, so you could precede this with a separate pattern to match the
Function fact. So the whole rule might look like

 (defrule Function-Parameter-Required-Passed
       "Check current Function Required Parameter"
       (Input (name Function) (value ?functionName))
       (Function (name ?functionName))
       (not (and (Function (name ?functionName)
                           (requiredParameter $?before ?param $?after))
                  (not (Param (name ?param)))))
       => ...


>       =>
>       (printout t "All Parameter Passed" crlf)
> )
> 
> 
> (defrule Function-Parameter-Required-NOT-Passed
>       "Check current Function Required Parameter"
>       (Input (name Function) (value ?functionName))
>       (Function (name ?functionName)(requiredParameter
> $?requiredParameterList))
> 
>       ;; 2. check


This one is the opposite of the above, so we could actually just
enclose the whole thing in yet another not; (not (not)) is "exists",
though, so let's use that:


 (defrule Function-Parameter-Required-Passed
       "Check current Function Required Parameter"
       (Input (name Function) (value ?functionName))
       (Function (name ?functionName))
       (exists (and (Function (name ?functionName)
                              (requiredParameter $?before ?param $?after))
                    (not (Param (name ?param)))))
       => ...


> 
>       =>
>       (printout t "Parameter Missing : (missing parameters)" crlf)
> 
> )

Make sense?

---------------------------------------------------------
Ernest Friedman-Hill  
Science and Engineering PSEs        Phone: (925) 294-2154
Sandia National Labs                FAX:   (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]
--------------------------------------------------------------------

Reply via email to