Created
March 7, 2017 21:14
-
-
Save deque-blog/9c5dab1fedc8dd408d57953700cb930e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn zip | |
"Create a sequence of tuples, each element being drawn from one collection" | |
[& colls] | |
(apply map vector colls)) | |
(defn pick-n-of-each | |
"Pick n `elements` for each of the `groups` starting from the beginning" | |
[n elements groups] | |
(zip elements (mapcat #(repeat n %) groups))) | |
(defn randomly-pick-n-of-each | |
"Pick n `elements` for each of the `groups` randomly" | |
[n elements groups] | |
(pick-n-of-each n (shuffle elements) groups)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment