Thank you for that clarification, Ernest. A couple of follow-ups: 1) NOT to belabor the issue, but I'll assume that the not 'function' behaves as the test function in that non TRUE or FALSE atoms are evaluated to TRUE (resulting in the not function returning the atom FALSE), correct? 2) Now you have me thinking about the 'not' function with regard to performance: So (test (not ...)) is implemented as a 'not function' rather than a 'not node' as would (not (test ...)). And I understand that every (not (xxx)) CE creates a UNIQUE node, even if the same (not (xxx)) appears in multiple rules. Furthermore, I would think that a (test (xxx)) CE can create sharable nodes. What is the relative performance of coding (not (test xxx)) vs (test (not xxx)), particularly where this same pattern occurs in multiple rules? Jack [EMAIL PROTECTED] wrote: > Hi Jack, > > The 'test' CE succeeds when the function call evaluates to a value > that is not the atom FALSE. I.e., other atoms, numbers, TRUE, external > addresses, etc, all succeed. Only the atom FALSE fails. This is an > excellent question, and I was surprised to find that the manual > doesn't state this specifically. It will now! > > Now, the 'not' CE is entirely different. The 'not' CE doesn't work > with function calls, it works with other CEs. If you write, as you do > below, > > (defrule foo1 > ... > (not (str-index "foo" "foo was here")) > ... > (not (+ 1 1)) > > these patterns will succeed as long as there are no -facts- which look > like (str-index "foo" "foo was here") or (+ 1 1). I.e., these CEs have > nothing whatsoever to do with the functions str-index or + despite > appearances. The functions will never be called. > > You can write (not (test (function-call))), though, and this is more > or less the same as (test (not (function-call))), but implemented > differently. In the first case, you're using the 'not' CE -- i.e., > there's a 'not' node in the Rete network. In the second case, you're > using the 'not' function: i.e., the 'test' CE's evaluates a 'not' > function with a 'function-call' function call as an argument. > > I think Jack Kerkhof wrote: > > Hi all, > > > > What is the DEFINED behavior for CE's (I.E. 'not' & 'test') when they > > are passed a non-boolean value? > > > > Context: > > > > A number of the Jess functions return EITHER a boolean or some other > > value (I.E. str-index, member$, system...) > > When these are used in a CE, what is the DEFINED behavior when the > > function return value is non-boolean? > > > > Experimentation seems to indicate that the non-boolean value is > > generally evaluated to true, but I don't really see this documented, so > > I'm not sure how to properly handle such cases. > > > > In particular, what is the RIGHT way to code function patterns with two > > possible return types? > > > > A few examples: > > > > (defrule foo1 > > (test (str-index "foo" "foo was here")) > > (test (> (str-index "foo" "foo was here") 0) ) > > (not (str-index "foo" "foo was here")) > > (not (str-index "goo" "foo was here")) > > => > > (printout t "index " (str-index "foo" "foo was here") " matches > > test, test >0, not, not goo!" crlf) > > ) > > > > > > (defrule foo2-contrived-eg > > (test (+ 1 1)) ; Dont' try this at home - but jess does accept it... > > > > (not (+ 1 1)) > > => > > (printout t "1+1 both tests and not!" crlf) > > ) > > > > The apparent overloaded behavior of test and not can be useful in some > > contexts, but is it legitimate? > > > > Jack > > > > (ps tested in jess 5.xxx) > > > > > > --------------------------------------------------------------------- > > 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] > > --------------------------------------------------------------------- > > > > --------------------------------------------------------- > Ernest Friedman-Hill > Distributed Systems Research Phone: (925) 294-2154 > Sandia National Labs FAX: (925) 294-2234 > Org. 8920, MS 9012 [EMAIL PROTECTED] > PO Box 969 http://herzberg.ca.sandia.gov > Livermore, CA 94550 > > --------------------------------------------------------------------- > 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] ---------------------------------------------------------------------
