> (defquery find-conditions
>   (declare (variables ?wantedConditionCode))
>   (event (conditionCodeId ?ccId&:( = ?wantedConditionCode))))
 
    1.  The = conditional element (CE) seems wrong.
        It reduces to (= ?x), which is a vacuous test that always returns TRUE.
        A test CE doesn't "inherit" the variable name; you have to write it
        explicitly.  It should be:
 
    1.'      ?ccId&:(= ?ccId ?wantedConditionCode)
 
        (Note: The Jess in Action book, p.391, states that the math functions,
        including the = function, takes argument list  <number> <number>+,
        where the '+' is regexp syntax for "1 or more".  Actually, { -, /, ** } takes
        <number>+, and are OK with 1 arg but throw an exception with 0 args,
        while { +, *, =, <, >, <=, >=, <> } take <number>*, and are fine even with
        0 args.  (+) returns 0, (*) returns 1, and the (in)equalities with 0 or 1 arg
        always return TRUE.)
 
    2.  The = CE is unnecessary.  Just match on the variable directly:
 
    (defquery find-conditions-tersely
        (declare (variables ?c))
        (event (conditionCodeId ?c)))
 
    In retrospect, I don't know why your query generated nothing.
    In my test, version #1 errs to the other extreme: it matched _every_
    occurrence of the template, regardless of the value passed in.
    Version #2 worked properly.
--
Eric Wang
CAD Lab, School of Mechanical Engineering, Sungkyunkwan University
 

Reply via email to