dom-top icon indicating copy to clipboard operation
dom-top copied to clipboard

Loopr performance

Open KGOH opened this issue 1 year ago • 0 comments

sup! First of all, awesome library and I'm not judging anyone for their unorthodox control flow views.

Second of all, there's a typo in the loopr docstring https://github.com/aphyr/dom-top/blob/375df6397c78559a18c376860af0475373af95cd/src/dom_top/core.clj#L728 It should be (let [[count sum] ...

Third of all, I observe that a transduce is 20-30% faster than loopr:

(transduce
  cat
  (fn ([[count sum] x] [(inc count) (+ sum x)])
      ([[count sum]] (/ sum count))
      ([] [0 0]))
  [[1 2 3] [4 5 6] [7 8 9]]) #_5

KGOH avatar Jun 03 '24 12:06 KGOH