You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs currently indicate the functions that need to be supplied to create a custom accumulator, and there are example in that the Clara codebase has accumulators created in the same way. However, I think the docs could benefit from an annotated concrete example of how to write a custom accumulator. This is something we might want to link to from the main accumulator page rather than putting it there in order to avoid clutter on the main page and keep it focused on the majority use-cases. The current docs:
Writing Accumulators
Clara provides a rich set of built-in accumulators, but advanced use cases may require customized accumulators over a collection of facts. Accumulator authors use the accum function in the clara.rules.accumulators namespace, and must provide these parts:
reduce-fn - A reduce function, in the style of clojure.core.reducers, which reduces a collection of values into a single output.
combine-fn - A combine function, in the style of clojure.core.reducers, which combines the outputs of two reduce-fn operations into a new, single output.
initial-value - An optional parameter that will be passed to the reduce-fn if provided. If all bindings are bound by other conditions in the rule or query then a non-nil initial value will be used as the result even if there are no matching facts to accumulate on.
retract-fn - An optional function that accepts a previously reduced output and a fact, and returns a new reduced output with the given fact retracted.
convert-return-fn - an operation that performs some conversion on the reduce/combine value before returning it to the caller
The text was updated successfully, but these errors were encountered:
The docs currently indicate the functions that need to be supplied to create a custom accumulator, and there are example in that the Clara codebase has accumulators created in the same way. However, I think the docs could benefit from an annotated concrete example of how to write a custom accumulator. This is something we might want to link to from the main accumulator page rather than putting it there in order to avoid clutter on the main page and keep it focused on the majority use-cases. The current docs:
The text was updated successfully, but these errors were encountered: