This project is read-only.

aggregate(func[, arg])

Applies an accumulator function over a sequence.

Syntax

Parameters

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 sentence = "the quick brown fox jumps over the lazy dog";

// Split the string into individual words.
var words = sentence.split(' ');

// Prepend each word to the beginning of the 
// new sentence to reverse the word order.
var reversed = $from(words).aggregate(
    "(workingSentence, next) => next + ' ' + workingSentence");
document.writeln(reversed);

// This code produces the following output:
//
// dog lazy the over jumps fox brown quick the 

Last edited May 16, 2012 at 4:55 AM by suckgamoni, version 2

Comments

No comments yet.