Opened 12 years ago

Closed 12 years ago

#4461 closed enhancement (fixed)

Propose to add dojo.reduce

Reported by: guest Owned by: anonymous
Priority: low Milestone:
Component: Core Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

dojo.reduce will iterate the array, apply the callback function to each element and return a scalar value back. This function template is a good candidate for min/max/sum implementation.

A typical example is:

dojo.reduce([6,2,5,8,3], function(reduced, item) {
	return reduced < item ? reduced : item;
});

the result is 2.

Attached is the diff of dojo/_base/array.js and dojo/tests/_base/array.js

Attachments (1)

reduce.diff (1.7 KB) - added by guest 12 years ago.
Diff of dojo.reduce, src and test case.

Download all attachments as: .zip

Change History (3)

Changed 12 years ago by guest

Attachment: reduce.diff added

Diff of dojo.reduce, src and test case.

comment:1 Changed 12 years ago by Tom Trenka

This may be a nice addition but it is useless to us without knowing who submitted it and whether or not they have a CLA on file. If whoever submitted could update this ticket with that information, we might consider it for inclusion to the codebase.

comment:2 Changed 12 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

Closing with the checkin of dojox.lang.functional.

Note: See TracTickets for help on using tickets.