Advertisement
grimnebulin

Untitled

Jun 3rd, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function callManyTimes(minIndices, maxIndices, func) {
  2.     doCallManyTimes(minIndices, maxIndices, func, [], 0);
  3. }
  4.  
  5. function doCallManyTimes(minIndices, maxIndices, func, args, index) {
  6.     if (maxIndices.length == 0) {
  7.         func(args);
  8.     } else {
  9.         var restMin = minIndices.slice(1);
  10.         var restMax = maxIndices.slice(1);
  11.         for (args[index] = minIndices[0]; args[index] < maxIndices[0]; ++args[index]) {
  12.             doCallManyTimes(restMin, restMax, func, args, index + 1);
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement