Skip to content

Instantly share code, notes, and snippets.

@athos
Created October 12, 2016 09:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athos/5700751dc13028ed1a5e232fa84b13b6 to your computer and use it in GitHub Desktop.
Save athos/5700751dc13028ed1a5e232fa84b13b6 to your computer and use it in GitHub Desktop.
(defn with-retry [n f]
(letfn [(try-once [i]
(try
(f)
(catch Exception e
(if (pos? i)
#(try-once (dec i))
(throw e)))))]
(trampoline try-once n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment