On 29.04.2009, at 21:44, samppi wrote: > Could someone give me a simple example of when > clojure.contrib.accumulators is useful? Its use seems to involve > collections (and numbers) that have the :clojure.contrib.accumulators/ > accumulator type, and it has some general multimethods for adding and > combining, but what does it add that conj and concat do not provide? > contrib.monads/writer-m seems to suggest using accumulators, too...
My main motivation for writing that library was to have a generic interface to many kinds of accumulators for use in contrib.monads/ writer-m. The writer monad is of little use if a specific type of accumulator is hard-coded into it, as different applications need to accumulate quite different data items. The same need for a generic interface exists in other situations. For example, in one of my applications I have a tree data structure with a generic "accumulate leaf values" operation that uses the accumulator multimethods. In addition to the generic accumulator interface, the accumulator library contains implementations of non-trivial accumulators such as counter, min-max, or mean-variance. I use these three a lot for statistics, with counter for producing histograms. Konrad. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---