Julia – MapReduce
Last Updated :
23 Feb, 2023
The map() and reduce() are the higher-order functions that are found in almost every programming language. The mapreduce() can be used to perform the task of an individual map() and reduce() together.
Syntax:
mapreduce(f, op, itr)
Like “mapreduce(f, op, v0, itr)”, this cannot be used with empty collections.
Example 1: Below is the Julia program to implement mapreduce:
Julia
mapreduce(x - >x^x, + , [ 1 , 2 , 3 ])
|
Output:
Example 2: Below is the Julia program to implement mapreduce:
Julia
mapreduce(x - > - x, * , [ 8 , 9 , 10 ])
|
Output:
Share your thoughts in the comments
Please Login to comment...