Open In App

Julia – MapReduce

Last Updated : 23 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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:

Output_1

 

Example 2: Below is the Julia program to implement mapreduce:

Julia




mapreduce(x->-x, *, [8, 9, 10])


Output:

Output 2

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads