taskPool.map() and taskPool.amap()
In this lesson, you will learn the use of map() and amap() functions.
We'll cover the following...
taskPool.map()
It helps to explain map()
from the std.algorithm
module before explaining taskPool.map()
. std.algorithm.map
is an algorithm commonly found in many functional languages. It calls a function with the elements of a range one-by-one and returns a range that consists of the results of calling that function with each element. It is a lazy algorithm, meaning it calls the function as needed. (There is also std.algorithm.each
, which is for generating side effects for each element, as opposed to producing a result from it.)
The fact that std.algorithm.map
operates lazily is very powerful in many ...