我正在尝试在循环中为node.js使用拉丁方库来查找某些模式,运行脚本并在2分钟后出现此错误:
RangeError:超出最大调用堆栈大小
var latinSquare = require("latinsquare");
var lookup;
var loop;
lookup = ls();
console.log("first: "+ lookup);
/*---------------------------------------------------------------------------------------------------------------------------------*/
function find() {
lookup = ls();
console.log("loop: " + lookup);
if(codeM(000000) == "1558" && codeM(111111) == "8691"){
console.log("find: " + lookup);
clearInterval(loop);
}
}
loop = setInterval(find,500);
/*---------------------------------------------------------------------------------------------------------------------------------*/
function ls(){
var table = [];
lookup = latinSquare.generate([0,1,2,3,4,5,6,7,8,9]);
for(i=0;i<lookup.length;i++){
for(d=0;d<lookup[i].length;d++){
table.push(lookup[i][d]);
}
}
return table;
}
/*---------------------------------------------------------------------------------------------------------------------------------*/
function codeM(data){
// this function return a result of mathematic procces. not call another function.
}
function padLeft(nr, n, str){
return Array(n-String(nr).length+1).join(str||'0')+nr;
}
答案 0 :(得分:0)
嗯...要在数学函数中寻找模式,我需要下面的代码才能无限地工作。我是javascript的初学者,我不知道如何解决它
var latinSquare = require("latinsquare");
var count = 0;
的setInterval(函数(){
var table =[];
var search = latinSquare.generate([0,1,2,3,4,5,6,7,8,9]);
for(i=0;i<search.length;i++){
for(d=0;d<search[i].length;d++){
table.push(search[i][d]);
}
}
count++;
console.log(count +“......”+ table);
},100);