I have a block of code I need to execute in Clojure that looks like:
(map function coll)
However, I need to delay the interval of time between each successive function call. That is, I want to call function
with the first item, then sleep for 10 seconds, then call with the second item, etc.
How can this be accomplished?
Thanks in advance for your help.
Just for the sake of completeness, following the discussion in the comments, this is what an implementation using doseq
would look like wrapped in a neat little function:
(defn doseq-interval
[f coll interval]
(doseq [x coll]
(Thread/sleep interval)
(f x)))
And here's how you would call it:
(doseq-interval prn (range 10) 1000)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With