How to iterate in recursion?
-
Hi, Is there any good and easy way to iterate through all the outcomes of recursion? Basically, I've a maze solver algorithm which solves maze instantly and prints the solved maze. I've broken down the code into each recursive call, and I need iterate to through it one by one..like if I press some button, then execution should stop at that point and maze state should be returned to main class and execution should proceed from the same point when I press some button. There is java applet on this website, I need to make one similar to it. [^] Any help would be appreciated. Thanks, Shivam Kalra
-
Hi, Is there any good and easy way to iterate through all the outcomes of recursion? Basically, I've a maze solver algorithm which solves maze instantly and prints the solved maze. I've broken down the code into each recursive call, and I need iterate to through it one by one..like if I press some button, then execution should stop at that point and maze state should be returned to main class and execution should proceed from the same point when I press some button. There is java applet on this website, I need to make one similar to it. [^] Any help would be appreciated. Thanks, Shivam Kalra
The
yield
keyword and this article[^] might help. :)Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
The
yield
keyword and this article[^] might help. :)Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
I know. Is there any way of implementing "yield" on your own?
-
I know. Is there any way of implementing "yield" on your own?
yes, you could do what the compiler does with
yield
, i.e. save and restore the entire state of the locals of all the nesting levels; it easily becomes quite cumbersome and I can't recommend it. :)Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
yes, you could do what the compiler does with
yield
, i.e. save and restore the entire state of the locals of all the nesting levels; it easily becomes quite cumbersome and I can't recommend it. :)Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
Alright. Thanks! :)
-
Alright. Thanks! :)
you're welcome. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.