List of utility methods to do Array Max Matrix
matrix(rows, cols, initial)Array.prototype.matrix = function (rows, cols, initial) { var arr = []; for (var i = 0; i < rows; i++) { var columns = []; for (var j = 0; j < cols; j++) { columns[j] = initial; arr[i] = columns; return arr; var matrix = [].matrix(3, 3, 10); console.log(matrix); arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; result = arr.reduceRight(function reduce(sum, value) { return "" + sum + value; }); console.log(result); | |
max2d( si, ei, sj, ej, calc_maxm, update_array )Array.prototype.max2d = function ( si, ei, sj, ej, calc_maxm, update_array ) { var maxm = 0.0; for ( var ip = si; ip <= ei; ip++ ) { for ( iq = sj; iq <= ej; iq++ ) { if ( calc_maxm ) { this[ip][iq] = calc_maxm.call(this,this[ip][iq]); if ( this[ip][iq] > maxm ) { maxm = this[ip][iq]; ... | |
maxChildren(childrenPos)Array.prototype.maxChildren = function(childrenPos) { if (childrenPos.length == 1) { return childrenPos[0]; if (this[childrenPos[0]] >= this[childrenPos[1]]) { return childrenPos[0]; } else { return childrenPos[1]; |