Skip to content

Instantly share code, notes, and snippets.

@dimovich
Created April 12, 2018 20:11
Show Gist options
  • Save dimovich/cabcfef4063aa826126e23f30f9b5b63 to your computer and use it in GitHub Desktop.
Save dimovich/cabcfef4063aa826126e23f30f9b5b63 to your computer and use it in GitHub Desktop.
(defn update-stats
"Take a collection of pages and update stats (fns)."
[pages & [fns]]
(let [fns (or fns [update-stat1 update-stat2 clean-page])
xform (apply comp (map (partial map) fns)) ;;create transducer from
;;collection of functions
in-chan (async/chan 1)
out-chan (async/chan 1)]
(async/onto-chan in-chan pages)
(async/<!! (async/pipeline 4 out-chan xform in-chan))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment