0

I have 5 loops, one inside the other:

for (int k; k< files.length; k++){
   var subFiles = files[k];
    for (int t; t<subFiles.length; t++){
         call(files[k], subFiles[t]);
       ... and so on    
  }
}

is there an elegant way to do it? I think about recursion, but I am concerned about heap memory.

The application is written in node.js.

2
  • you may consider using FRP (functional reactive programming) as seen on github.com/baconjs/bacon.js ; depending on your problem it could lead to a cleaner implementation Commented May 26, 2014 at 9:13
  • 1
    I think, it would be better to change your data model files - make it less complex, split on several objects and iterate over it. Commented May 26, 2014 at 9:14

1 Answer 1

1

You could split it up into more functions, which makes the code cleaner to read. But in the end you will end up going into this loops. The Real question you should ask yourself is: Did i think my idea trough well enough. I never ran into a situation where i had 5 dimensional problems to solve.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.