c# - for loop doesn't process all values -


i have set of nested functions use in for-loop. for-loop doesn't process values.

snippet below:

..... ..... for(i=0;i<5;i++) {  a(); } ..... ....  a() {  for(j=0;j<5;j++)  {   b();   if j false return;  }  return; }  b() {  for(k=0;k<5;k++)  {   a();   if k false return;  }  return; } 

in above code, for-loop in b() not take values, takes single value , stops loop. problem in b()'s loop? how can process values?

in first iteration of first loop a() called. in first iteration of loop b() called. in first iteration of b's lop a() called. calls b() calls a() … until stack overflows.

you have created pair of mutually recursive functions without condition bottom out (stop) recursion.

removing loops a , b

a() {   b(); } b() {   a(); } 

more directly shows problem.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -