-
-
Save zane/58e3c77951eaa5159f26 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 backoff-seq | |
([xs] | |
(backoff-seq xs 0)) | |
([xs backoff] | |
(lazy-seq | |
(try (if-let [xs (seq xs)] | |
(cons (first xs) (backoff-seq (rest xs) (Math/floor (/ backoff 2)))) | |
nil) | |
(catch MyExceptionHere e | |
(Thread/sleep (* backoff 1000)) | |
(backoff-seq xs (* backoff 2 ))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment