Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Looking for the first item in the chain

by vagabonding electron (Curate)
on Aug 10, 2014 at 18:49 UTC ( [id://1096927]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1096927]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-18 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found