Skip to content

Instantly share code, notes, and snippets.

@ohpauleez
Created October 29, 2010 03:37
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 ohpauleez/652858 to your computer and use it in GitHub Desktop.
Save ohpauleez/652858 to your computer and use it in GitHub Desktop.
futures
user=> (future (+ 1 2 3))
#<core$future_call$reify__5403@d2d58b: 6>
user=> (def f *1)
#'user/f
user=> @f
6
user=> (map #(future (apply * %)) (partition-all (+ 2 num-of-cores) (range 25)))
(#<core$future_call$reify__5403@3d3c33b7: 0> #<core$future_call$reify__5403@3b6752c9: 840> #<core$future_call$reify__5403@7c6c2896: 7920> #<core$future_call$reify__5403@20dccfab: 32760> #<core$future_call$reify__5403@c5f468: 93024> #<core$future_call$reify__5403@4430d83d: 212520> #<core$future_call$reify__5403@62c4afc4: 24>)
user=> (def my-futures *1)
#'user/my-futures
user=> (map #(deref %) my-futures)
(0 840 7920 32760 93024 212520 24)
user=> ; *1 is shorthand for the last returned value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment