Reduce refers to the operation, where a array of items is reduced to a single value. Use with language tag like [c++], [google-sheets-formula]. Do NOT use alone.
Questions tagged [reduce]
3548 questions
1
vote
1 answer
How to efficiently test a deeply nested data value in puppet to take an action?
Given a data structure like
$local_users => {
"user" => {
"ssh" => {
"config_entries" => [
{ "host" => "dummyhost",
"lines" => [
"ProxyCommand /usr/bin/corkscrew proxy.example.net 8080 %h %p"
]
…

dbailey
- 1,417
- 1
- 10
- 16
1
vote
2 answers
Can not calculate sum of values in array via Reduce method?
I have been always using for to calculate any sum in a table, but I heard that there is a proper way, it is by using reduce, I followed the documentation and few examples using simple arrays, but I am using an array of objects, and here is my simple…

TaouBen
- 1,165
- 1
- 15
- 41
1
vote
2 answers
No Idea how to create a specific MapReduce in CouchDB
I've got 3 types of documents in my db:
{
param: "a",
timestamp: "t"
} (Type 1)
{
param: "b",
partof: "a"
} (Type 2)
{
param: "b",
timestamp: "x"
} (Type 3)
(I can't alter the layout...;-( )
Type 1 defines a start timestamp, it's like the start…

philipp
- 93
- 8
1
vote
1 answer
RavenDB query with projection with parent and last child entry for certain date range
Let's say I have Post and a Collection of Comments,
public class Post {
String title;
List comments;
}
public class Comment {
Date date;
String author;
String comment;
}
I would like to be able to know for a certain post title what is…

JohnSilver
- 11
- 2
1
vote
4 answers
Print two or more occurrences using reduce() in Javascript
So I have this array of pilots :
var pilots = [
{
id: 10,
name: "Poe Dameron",
years: 14,
},
{
id: 2,
name: "Temmin 'Snap' Wexley",
years: 30,
},
{
id: 41,
name: "Tallissan Lintra",
years: 16,
},
{
…

klevisx
- 175
- 1
- 2
- 12
1
vote
1 answer
typescript: grouping in multidimensional array of objects (by id)
I need help implementing the following function definition:
I don't know how to deal with multidimensional arrays as such
input (grouped by date)
[
{date: 1552489200000, data: [{id: 1, value:100}, {id: 2, value: 101}]},
{date: 1552575600000,…

d.Foo
- 63
- 9
1
vote
3 answers
Using only `.reduce()` to swap 2 elements in the array in JavaScript?
I would like to find out if swapping elements can be done using only .reduce in JavaScript. If not, what else should be used from the functional programming land?
This is not for sorting an array. I wanted to find all the permutations of the array…

shivangg
- 521
- 8
- 15
1
vote
0 answers
Reduce list of interval(begin & end time) to get maximum no of non-overlapping function that we can attend in a day
I am creating a Java 8 program which gives the maximum number of functions that a person can attend in a day. i.e) A person can be present in only one function at any given time interval.
I tried coding to get the solution but was not able to find…

RamkumarSP
- 55
- 5
1
vote
1 answer
Why should these algorigthms behave any differently?
For personal edification, I'm fiddling around with Swift's .reduce() and I've run into an unusual behavior which I can't understand.
I spent quite a lot of unexpected time (at least 6 hours) researching and experimenting, and I'm stumped.
I have…

NonCreature0714
- 5,744
- 10
- 30
- 52
1
vote
2 answers
How to merge multiple data.frames with Reduce and get an ordered output?
There is a classic approach how to simultaneously merge multiple data.frames in a list.
The output, however, is somewhat disordered.
Example
> L
[[1]]
a b c d e
1 5 2 4 10 1
[[2]]
a b c d e
1 6 7 4 6 1
[[3]]
a b c d
1 7 3 5 5
[[4]]
a b c…

jay.sf
- 60,139
- 8
- 53
- 110
1
vote
1 answer
Several Typescript (is not assignable to parameter of type) errors on Reduce function
[ts]
Argument of type '(sum: number, wallet: IConvertedRate) => number' is not assignable to parameter of type '(previousValue: number, currentValue: "" | { convertedRate: number; }, currentIndex: number, array: ("" | { convertedRate: number; })[])…

Leon Gaban
- 36,509
- 115
- 332
- 529
1
vote
1 answer
angular foreach problems when adding new items
I have an angular application with Firebase. I want to change the value of an firebase item. Everytime the total KM changes it needs to be set to the right value. so this is my services:
countKm(){
this.totalKmRef = this.db.list(this.uid +…

Joppe Meijers
- 81
- 1
- 9
1
vote
2 answers
Using reduce to populate a [String : [CGFloat]] dictionary from an object array
I have an array of objects, which each have a category and an amount, as below:
Record("Bills", 150.00), Record("Groceries", 59.90), etc...
I'd like to use reduce to populate a [String:[CGFloat]] dictionary.
It should be like this:
[ "Bills" :…

David Spry
- 119
- 2
- 8
1
vote
3 answers
How to combine 2 arrays into 1 object javascript
I have 2 arrays that i want to "reduce" into 1 object.
so for instance:
I have..
var originalData = [1,2,3];
var newData = [3,1,2];
i want to combine these two arrays into an object that looks like this:
var newOrderObject = {1:3, 2:1, 3:2};
im…

zomdar
- 263
- 2
- 6
- 22
1
vote
6 answers
Hadoop Map Reduce Program
When I was trying the Map Reduce programming example from Hadoop in Action book based on Hadoop 0.20 API I got the error
java.io.IOException: Type mismatch in value from map: expected org.apache.hadoop.io.IntWritable, recieved…

Sri
- 201
- 2
- 4
- 6