Fork me on GitHub
#clara
<
2016-09-04
>
wparker00:09:32

@flavio Do you mean that you were trying to do something like (def oldest-person (acc/max (.getAge) :returns-fact true)) ? (.getAge) isn’t a valid Clojure expression; an interop form needs a target to invoke on. http://clojure.org/reference/java_interop might be helpful if you’re unfamiliar. Introducing the ?name binding in the accumulator will cause you to accumulate once per name, which doesn’t seem like what you would want in this example case. As chance would have it, I have a PR open to clara-site that discusses the subject. https://github.com/rbrush/clara-site/pull/8

wparker00:09:08

That grouping behavior isn’t new to 0.12, but there were some bugs around it before that were fixed in 0.12

flavio15:09:39

@wparker , thanks for the updated documentation on the accumulators. This explains the constraint part of the accumulator. I have now successfully run following example: (defrule get-old-person-count [?old-person-count <- (acc/count) :from [Person]] => (println (str "The number of elderly persons is " ?old-person-count)) ) Which returns the number of Person facts as expected. However, I am still struggling with accumulators expecting a field to work with: (defrule get-old-person-max-age [?oldest-age <- (acc/max :age ) :from [Person]] => (println (str "The oldest person is aged: " ?oldest-age)) ) Above rule throws a null pointer exception as it doesn't know what :age is. My question is how can I pass a field name to an accumulator where the field name comes from a Java Bean. I went through the Interop documentation multiple times but I can't seem to get it right. Thanks