Closed sbelak closed 6 years ago
@sbelak this is excellent, thank you. My preference would be for min
and max
to return nil in the degenerate case. You're right that this seems more consistent with the rest of the API (for better or worse...).
If you could update the PR I'll merge it in.
Changed to a hybrid version. I wanted to avoid another nil check at each step, but it might be better to do the straightforward version. Your call.
Also changed share
to return a double to me more consistent as we work with and coerce to double everywhere else.
Any chance you can publish to Clojars. We're just about to release 0.30 of Metabase and I'd love to switch over.
Done, just released v0.4.1 🎉
This adds a couple more reducing functions that I always end up writing (
min
,max
,share
), and a version ofmonoid
that works with transducers.I'm not entirely sure it is correct for
min
to returnDouble/POSITIVE_INFINITY
. It is an identity wrt to min, but can mess up other math operations if you don't expect it (or just look weird). An alternative would be to return nil, which is consistent with behaviour elsewhere when working with empty datasets.