Welcome to the Monastery | |
PerlMonks |
Re: Subsets and adjacent valuesby grinder (Bishop) |
on May 30, 2008 at 13:59 UTC ( [id://689215]=note: print w/replies, xml ) | Need Help?? |
As much as I am chuffed that you're using a module I wrote, I'm afraid there's a much easier way of doing this. Just set down a marker at the beginnning of the list, move the right marker down as far as the shortest length of subset you want, and then start pushing out out the subsets as you move to the end of the string. When you get to the end, move the beginning marker one to right, and repeat while you can continue to squeeze out a subset. Then stop. Programmatically, this gives:
This will be really, really fast. If you try your approach on a powerset of 30 elements your program will still be running after the heat-death of the universe. update: oops, BrowkerUK beat me to it. That'll teach me to get side-tracked into a conversation in real life and leave the form in preview mode. Still, it's interesting to compare the two techniques: he chose start postition and length, I chose start and end positions. Pick your poison :) • another intruder with the mooring in the heart of the Perl
In Section
Seekers of Perl Wisdom
|
|