Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: How can sets be recursively concatenated when intersecting with each otherby SuicideJunkie (Vicar) |
on Apr 24, 2011 at 21:56 UTC ( [id://901099]=note: print w/replies, xml ) | Need Help?? |
FYI: you can use (0..$#cluster) rather than hardcoding magic numbers, and push onto the array to simplify your initialization (see below). Are important to include too. Example (with array names pluralized for clarity):
Definitely put some debug prints into your loop so you can see if what it is actually doing is what you expect it to be doing at each step. PS: I'd suggest having a list of superclusters, and adding one cluster at a time. If the new cluster has no intersections with anything, add it to the list as a new supercluster. If it has an intersection with something, add it to that supercluster and keep searching. For every intersection after the first, add the intersecting supercluster to the originally matched supercluster, and then completely remove the new match (take care about the list shrinking by 1 when you do that). That way, your debug output could show something like:
In Section
Seekers of Perl Wisdom
|
|