Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^3: how to find combine common elements of an array?by BrowserUk (Patriarch) |
on Apr 25, 2011 at 16:40 UTC ( [id://901214]=note: print w/replies, xml ) | Need Help?? |
I noticed a couple areas where yours could be improved efficiency wise and one potential bug: That is a big improvement, especially fixing the bug. The redo instead of goto is so obvious ... yet I didn't see it. I'm definitely a fan of jaredor's solution below Me too. At least, jaredor's second solution. Which I'd missed till now. I did see his original solution and my eyes zeroed in on this line:
There's a lot of potentially expensive processing going on in that one line. Repeating that every time around the outer loop of a large set of data smacked of "expensive". By contrast, his second solution is almost magical in its simplicity and deserves elevating to tutorial. I wouldn't mind betting that many of the graphing packages (and their authors) could learn a lot from that unremarkable looking piece of code. then realized that there didn't need to be an identified element per subgraph... Don't you just love understatement :) Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|