pcalls invokes any number of zero-argument functions in parallel and returns their results as a lazy sequence. Results retain input order, while evaluation uses futures, making pcalls useful for side-effecting parallel transformations. section 9.1.5
Listing 9.5. → Parallel computation, Lazy sequences
(pmap ([f coll]) ([f coll & colls])) (pcalls [& fns]) (pvalues [& exprs])
Use the compact signature to remember that pcalls accepts zero or more functions, each requiring no arguments. section 9.1.5
Calling independent functions
(pcalls (constantly "Function") #(System/currentTimeMillis) #(println "side-effect")) ;; side-effect ;; ("Function" 1553770187108 nil) The printing function returns nil, and the resulting sequence follows the functions' order. section 9.1.5
Keep these behavioral details in mind:
- Pass zero or more functions; every function must have arity zero. section 9.1.5
- Realize the lazy sequence to obtain results; parallel evaluation does not change their sequence order. section 9.1.5
