Skip to content

Instantly share code, notes, and snippets.

@oranenj
Created February 4, 2009 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oranenj/58262 to your computer and use it in GitHub Desktop.
Save oranenj/58262 to your computer and use it in GitHub Desktop.
(defn side-effector [f interval aseq]
(let [counter (atom 0)
work (fn [item]
(swap! counter inc)
(when (= @counter interval)
(f item)
(swap! counter (fn [_] 0))
item))]
(for [x aseq] (work x))))
(side-effector #(println "Hooray, I have " %) 2 '(1 2 3 4 5 6 7 8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment