我有一个代码块,我想将其转换为不使用 for 或 while 循环的递归代码块。建议?
sprite = function(dataset, pos){
var size ={nrows : 3, ncolumns :3};
var data = [];
for(row = pos.row0; row < pos.row0+size.nrows; row++) {
for(column = pos.column0; column < pos.column0+size.ncolumns; column++) {
if(column == pos.column0) {
data.push([dataset[row][column]]);
} else {
data[row].push(dataset[row][column]);
}
}
}
return data;
}