Skip to content

Instantly share code, notes, and snippets.

@zane zane/gist:58e3c77951eaa5159f26 Secret
Last active Aug 29, 2015

Embed
What would you like to do?
(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
You can’t perform that action at this time.