build/ludorum.js
/** Two `aggregate`d distributions make a new distribution with a combination of the domains. By
	default the value combination function `comb` is the sum. An equality test `eq` can be provided
	if the combinations cannot be compared with `===`.
	*/
Two `aggregate`d distributions make a new distribution with a combination of the domains. By
default the value combination function `comb` is the sum. An equality test `eq` can be provided
if the combinations cannot be compared with `===`.
Two ` aggregate ` d distributions make a new distribution with a combination of the domains . By default the value combination function ` comb ` is the sum . An equality test ` eq ` can be provided if the combinations cannot be compared with ` === ` .
function aggregate(dist1, dist2, comb, eq) {
		var distR = [];
		comb = comb || function (v1, v2) {
				return v1 + v2;
			};
		eq = eq || function (v1, v2) {
				return v1 === v2;
			};
		Iterable.product(dist1, dist2).forEachApply(function (p1, p2) {
			var v = comb(p1[0], p2[0]);
			for (var i = 0; i < distR.length; i++) {
				if (eq(distR[i][0], v)) {
					distR[i][1] += p1[1] * p2[1];
					return;
				}
			}
			distR.push([v, p1[1] * p2[1]]);
		});
		return distR;
	}
function aggregate ( dist1 , dist2 , comb , eq ) { var distR = [ ] ; comb = comb || function ( v1 , v2 ) { return v1 + v2 ; } ; eq = eq || function ( v1 , v2 ) { return v1 === v2 ; } ; Iterable . product ( dist1 , dist2 ) . forEachApply ( function ( p1 , p2 ) { var v = comb ( p1 [ 0 ] , p2 [ 0 ] ) ; for ( var i = 0 ; i < distR . length ; i ++ ) { if ( eq ( distR [ i ] [ 0 ] , v ) ) { distR [ i ] [ 1 ] += p1 [ 1 ] * p2 [ 1 ] ; return ; } } distR . push ( [ v , p1 [ 1 ] * p2 [ 1 ] ] ) ; } ) ; return distR ; }
Two `aggregate`d distributions make a new distribution with a combination of the domains.
Two ` aggregate ` d distributions make a new distribution with a combination of the domains .