Returns the cross product of two sets (arrays) - Node.js Array

Node.js examples for Array:Set Operation

Description

Returns the cross product of two sets (arrays)

Demo Code

Array.prototype.cross = function (B) {
    var result = [];
    this.forEach(function (a) {
        B.forEach(function (b) {
            result.push([a,b]);/* w  ww  .  j a v  a2 s.c  o  m*/
        });
    });
    return result;
};

Related Tutorials