Tuple Results with Multiple functions and TaskPool

You will learn the use of multiple functions with tuples and the use of TaskPool in this lesson.

Multiple functions and tuple results

std.algorithm.map(), taskPool.map(), taskPool.amap(), and taskPool.reduce() can all take more than one function, in which case the results are returned as a Tuple. The results of individual functions correspond to the elements of the tuple in the order that the functions are specified. For example, the result of the first function is the first member of the tuple.

The following program demonstrates multiple functions with std.algorithm.map. Note that the return types of the functions need not be the same, as seen in the quarterOf() and tenTimes() functions below. In that case, the types of members of the tuples would be different as well:

Get hands-on with 1200+ tech skills courses.