aggregateSeed(seed, func[, arg])

Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.

Syntax

Parameters

seed
The initial accumulator value.
func
Type: function(accumulated, value, key, arg)
An accumulator function to be invoked on each element.
arg
An extra argument.
Return Value

The final accumulator value.

Examples

var ints = [ 4, 8, 8, 3, 9, 0, 7, 8, 2 ];

// Count the even numbers in the array, using a seed value of 0.
var numEven = $from(ints).aggregateSeed(0, 
    "(total, next) => next % 2 == 0 ? total + 1 : total");

document.writeln("The number of even integers is: " + numEven);

// This code produces the following output:
//
// The number of even integers is: 6 

Last edited May 16, 2012 at 4:56 AM by suckgamoni, version 3

Comments

No comments yet.