This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-13
Channels
- # adventofcode (4)
- # announcements (1)
- # babashka (7)
- # beginners (51)
- # calva (18)
- # cider (15)
- # clj-kondo (1)
- # cljsrn (6)
- # clojure (99)
- # clojure-dev (31)
- # clojure-europe (5)
- # clojure-france (2)
- # clojure-italy (3)
- # clojure-nl (14)
- # clojure-seattle (8)
- # clojure-spec (6)
- # clojure-uk (2)
- # clojurescript (23)
- # conjure (3)
- # css (6)
- # data-science (3)
- # datomic (19)
- # events (6)
- # fulcro (13)
- # graalvm (5)
- # honeysql (24)
- # inf-clojure (19)
- # music (10)
- # off-topic (28)
- # pathom (10)
- # rdf (15)
- # re-frame (11)
- # releases (4)
- # sci (1)
- # shadow-cljs (18)
Hi. Its not really a release as its just addressable as git coordinates right now, but i wanted some feedback if this was a general thing people might want. If you ever have a sequence operation that ends with (->> ... (sort-by f) (take N))
you pay the price to realize the entire collection. sorting kinda naturally falls outside of transduction contexts. This uses a bounded min-heap to accumulate the largest N
seen so far enabling (transduce xf (keep-heap 100 compare-fn) reducible-coll)
. It was motivated by querying a db, scoring in Clojure and only wanting to keep the top 100 results sorted by the scoring. The use of the heap enables taking N sorted results without keeping all of the elements in memory to sort them. https://github.com/dpsutton/heap-keep
This is cool - thanks for sharing. There is an x/sort-by
in https://github.com/cgrand/xforms (that just builds up a complete collection). Have you considered possibly submitting keep-heap
as an additional transducer to xforms (vs releasing a new lib)?