I think Roger Studner wrote:

> 
> (defrule count-icd9-codes
> 
> ?c <- (accumulate (bind ?count 0) ;; initializer
>             (bind ?count (+ ?count 1)) ;; action
>             ?count ;; result
>             (encounter (code ?c &: (eq ?c 440)))
>       )

...
> This (and anything in the accumlates match area) *always* returns 0 as the
> count variable. I took the example (modified) from the 7.0 'new features'
> area of the docs.


You've used the same variable ?c to mean two totally different things
in the same pattern: you're binding the result of the accumulate to
it, but you're also binding the contents of the "code" slot to
it. This is tricky enough that even I would have to trace through with
a debugger to see what will happen -- but I can guarantee you that it
won't be the answer you're expecting! 

Finally, note that there's no reason to write patterns like this

   (encounter (code ?c &: (eq ?c 440)))

when the following is equivalent but simpler, clearer, *and* more
efficient:

   (encounter (code 440))

Conveniently, making this change will also fix the problem outlined above!

---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          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