We define an Elixir function pmap using the Task API to convert sequential code into concurrent code by computing values asynchronously:
We can run this function to get the squares of numbers from 1 to 10000:
In the background, we’ve spawned 10000 processes to perform the same squaring operation on multiple data points simultaneously. We make use of all the cores and processors on our machine.