Day 2: Functional Parallelism
Today weâll continue our discussion of how functional programming helps with parallelism by looking at fold in more detail. But before we do that, weâll look at parallelizing our Wikipedia word count.
One Page at a Time
In day 1 we saw that the map function creates a sequence by applying a function to each element of an input sequence in turn. But thereâs no reason this has to happen seriallyâClojureâs pmap function operates just like map, except that the function is applied in parallel. Itâs semi-lazy, in that the parallel computation stays ahead of the consumption, but it wonât realize the entire result unless required.
We could, for example, convert our sequence of Wikipedia pages to a sequence ...
Get Seven Concurrency Models in Seven Weeks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.