Top "Reduce" questions

Reduce refers to the second step in a MapReduce computation, a component of a larger scalable, parallel-izable algorithm.

Finding the average of a list

I have to find the average of a list in Python. This is my code so far l = [15, 18, 2, 36, 12, 78, 5, 6, 9] print reduce(…

python list lambda average reduce
How to use filter, map, and reduce in Python 3

filter, map, and reduce work perfectly in Python 2. Here is an example: >>> def f(x): return x % 2 != 0 …

python python-3.x filter functional-programming reduce
Javascript reduce() on Object

There is nice Array method reduce() to get one value from the Array. Example: [0,1,2,3,4].reduce(function(previousValue, currentValue, index, array){ …

javascript arrays object reduce
Javascript reduce on array of objects

Say I want to sum a.x for each element in arr. arr = [{x:1},{x:2},{x:4}] arr.reduce(function(a,…

javascript functional-programming node.js reduce
NameError: name 'reduce' is not defined in Python

I'm using Python 3.2. Tried this: xor = lambda x,y: (x+y)%2 l = reduce(xor, [1,2,3,4]) And got the following error: l = …

python reduce python-3.2
What is the 'pythonic' equivalent to the 'fold' function from functional programming?

What is the most idiomatic way to achieve something like the following, in Haskell: foldl (+) 0 [1,2,3,4,5] --> 15 Or its equivalent …

python list functional-programming reduce fold
Reduce, fold or scan (Left/Right)?

When should I use reduceLeft, reduceRight, foldLeft, foldRight, scanLeft or scanRight? I want an intuition/overview of their differences - …

scala scala-collections reduce fold
Merging more than 2 dataframes in R by rownames

I gather data from 4 df's and would like to merge them by rownames. I am looking for an efficient way …

r merge dataframe reduce rowname
How to early break reduce() method?

How can I break the iteration of reduce() method? for: for (var i = Things.length - 1; i >= 0; i--) { if(…

javascript loops reduce
Reduce array to set in Swift

I am trying to reduce an array of objects to a set in Swift and this is my code: objects.…

arrays swift set reduce