aphyr / dom-top

Unorthodox control flow, for Clojurists with masochistic sensibilities.
Eclipse Public License 1.0
204 stars 8 forks source link

Loopr performance #9

Open KGOH opened 4 months ago

KGOH commented 4 months ago

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