in reply to Re^3: Looking for the first item in the chain
in thread Looking for the first item in the chain

Thank you very much Laurent_R , now I need a bit time to study your code, especially to internalize the flag system with $continue. I like the idea to instantly make the chains with push @{$predec{$pred}}, $succ; Thank you for your time.

Replies are listed 'Best First'.
Re^5: Looking for the first item in the chain
by Laurent_R (Canon) on Aug 10, 2014 at 21:42 UTC
    The $continue variable is just there to control the while loop. The idea is that you have to iterate on a data structure an unknown number of times. So long as you make a change, it means that further changes might be needed. But it you did not need to make any change, then you are guaranteed that you will not need to make any further changes. So you set $continue to true (1) before the loop, to make sure you enter the loop at least once. Then, you immediately set it to false (0). And, if you had to make any change, you set it to true (1), because you might have to iterate once more. But if you didn't need to make any change, then you are done, all the required changes have been done.

    Another monk previously called the same variable "changes" in another answer to this thread, but $changes and $continue have essentially the same purpose.

      Sorry for late responce and thank you very much again!