Skip to content

Instantly share code, notes, and snippets.

@mmower
Created August 7, 2013 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmower/c2fe70504df903ac2538 to your computer and use it in GitHub Desktop.
Save mmower/c2fe70504df903ac2538 to your computer and use it in GitHub Desktop.
(defmacro randomly
[& exprs]
`(eval (rand-nth (quote ~exprs))))
(defmacro randomly [& exprs]
(let [len (count exprs)
index (rand-int len)
conditions (map #(list '= index %) (range len))]
`(cond ~@(interleave conditions exprs))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment