|
module.exports.rand = function(n1,n2,e) { |
|
if (isNaN(num) || num === null) |
|
throw new RuntimeError( |
|
this.token, |
|
"Você deve prover valores para rand(n1,n2,e)." |
|
); |
|
if (e == undefined) { e = 0; } |
|
if (n1 == undefined && n2 == undefined) { return Math.random() * 2 - 1; } |
|
var data = Array.from(Array(n1),() => new Array(n2)); |
|
// benefit from creating array this way is a.length = number of rows and a[0].length = number of columns |
|
for (var i = 0; i < n1; i++) { |
|
for (var j = 0; j < n2; j++) { |
|
data[i][j] = e + Math.random() * 2 - 1; |
|
} |
|
} |
|
return aprox(data,5); |
|
}; |