Mark Elston (131) [Avatar] Offline
#1
The declaration of sequence used in parMap has it returning a Par[List[A]]. In the paragraph after defining parMap you state:


When we later call run, it will fork a single asynchronous computation which itself spawns N parallel computations...


I don't see how it can spawn N parallel computations when the return from sequence is a Par[List[A]]. Just following the types in sequence seems to indicate that the List of Par[A] entries passed to it are converted to a single Par (containing a List) coming out. How does this single Par result in "N parallel computations."

For example if A is Int then List[Par[Int]] is transformed to Par[List[Int]]. That is, it represents a single (potentially asynchronous) computation over a List of Ints.