Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created April 19, 2012 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/2418471 to your computer and use it in GitHub Desktop.
Save swannodette/2418471 to your computer and use it in GitHub Desktop.
loop.clj
(ns clj-play.core)
(set! *unchecked-math* true)
(defn sub-run ^long []
(let [r (java.util.Random.)]
(loop [result 0 j 0]
(if (< j 10000)
(recur (+ result (long (.nextInt r))) (inc j))
result))))
(defn run []
(loop [result 0 i 0]
(if (< i 10000)
(recur (+ result (sub-run)) (inc i))
result)))
(comment
(dotimes [_ 5]
(time (run)))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment