Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created January 31, 2011 21:39
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 amalloy/8fff306833f5d0852277 to your computer and use it in GitHub Desktop.
Save amalloy/8fff306833f5d0852277 to your computer and use it in GitHub Desktop.
(defn take-randnth [num coll]
(first
(nth
(iterate (fn [[ret candidates]]
(let [idx (rand-int (count candidates))]
[(conj ret (candidates idx))
(subvec (assoc candidates idx (candidates 0))
1)]))
[[]
(vec coll)])
num)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment