Skip to content

Instantly share code, notes, and snippets.

@johnjelinek
Last active August 29, 2015 13:56
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 johnjelinek/9282383 to your computer and use it in GitHub Desktop.
Save johnjelinek/9282383 to your computer and use it in GitHub Desktop.
(defn slow-seq [s ms]
(let [c (async/chan)]
(async/go
(loop [remain s]
(if (empty? remain)
(async/close! c)
(do
(async/<! (async/timeout ms))
(async/>! c (take 10 remain))
(recur (drop 10 remain))))))
(take-while identity (flatten (repeatedly #(async/<!! c))))))
(slow-seq (range 100) 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment