Last active
August 29, 2015 13:56
-
-
Save johnjelinek/9282383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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