Created
June 10, 2010 23:41
-
-
Save timcharper/433817 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 map-queue | |
"Like map, but populated eagerly via fill-queue | |
(map-queue odd? (range 1 10) :queue-size 5) ;; will always calculate 5 ahead of the last used item from the lazy sequence" | |
[f coll & options] | |
(apply fill-queue (fn [fill] (doseq [value coll] (fill (f value)))) options)) | |
(defn pmap-queue | |
"map-queue in parallel (using futures) | |
(pmap-queue odd? (range 1 10) :queue-size 5)" | |
[f coll & options] | |
(map deref (apply map-queue #(future (f %)) coll options))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment