You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From this, I would expect that the first argument is a function that takes the current result as first argument and the accumulator as second (as in JS's array.reduce). But it seems to be the other way around. For example, reduce(function(x, acc) { return x - acc; }, 1, [1, 2]) returns 0, where I would expect -2.
(The current reduce function seems to loop over the supplied array [1,2] from right to left, passing each value as x and the present result as acc.)
The text was updated successfully, but these errors were encountered:
The documentation gives this example use of reduce:
From this, I would expect that the first argument is a function that takes the current result as first argument and the accumulator as second (as in JS's array.reduce). But it seems to be the other way around. For example,
reduce(function(x, acc) { return x - acc; }, 1, [1, 2])
returns 0, where I would expect -2.(The current reduce function seems to loop over the supplied array [1,2] from right to left, passing each value as x and the present result as acc.)
The text was updated successfully, but these errors were encountered: