Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Looping through variable number of arrays variable times?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Julian Turner, post: 4904374"] Apologies for that. No doubt Richard's solutions are more effective, and recursion is not the best in terms of performance, but if you were still interested, here is a slightly adjusted version of my function to try. You could no doubt try speeding it up with use of "while" and "do while" loops, and reverse loops (i.e. length-1 --> 0) function LoopIt(e) { var L=e.length; var a=[]; Recurse(0); function Recurse(n) { if (n<L) { var m=n+1; for (var i=0; i<e[n][1]; i++) { a[n]=i; Recurse(m); } return; } var c=[]; for (var i=0; i<L; i++) { c[i]=new Array(e[i][0],a[i]); //alert(c[i].join(",")); } calculate(c); } } var example=[]; example[0] = new Array("A",2); example[1] = new Array("Q",4); LoopIt(example); Julian[/i][/i][/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Looping through variable number of arrays variable times?
Top