On Saturday, June 8, 2002, at 04:49 , John W. Krahn wrote:
[..]
> for ( split/(\d+-\d+(?::\d+)?),?/ ) {
>     next unless /\d/;
>     @x = /(\d+)/g;
>     if ( /-/ ) {
>         print "@x", @x == 2 ? " 1\n" : "\n";
>         }
>     else {
>         do  {
>             @y = ();
>             unshift @y, pop @x until $#x == $x[-1] - $x[0];
>             print "$x[0] $x[-1] 1\n";
>             } while ( @x = @y );
>         }
>     }

Major SplitFoo Mojo There.... my complements!

for those who may want a little help unwrapping how that plays,
I did a bit of 'insert debug statements' to show how the process
plays out:

cf http://www.wetware.com/drieux/pbl/perlTrick/doWhileLooper.txt

my own old fashion 'pointer arithmetic' style approach is up at

cf http://www.wetware.com/drieux/pbl/perlTrick/walkCommaSep.txt

{ I just happened to notice that this version will be able to
manage the case of 'non positive integers' that are not attempting
to be a part of a 'range'.... }

myFascistHouseMate laughed at me, that I should not whine if
the spec did not call for solving

        2,4,6,8

that one need not solve that to

        2 8 2

that talkes a bit more work....

cf http://www.wetware.com/drieux/pbl/perlTrick/walkCom2.txt

when they say, there is more than one way - they are clearly
not joking... the complicated part remains how to resolve
which faction to support.... here, well... I still am clueless.

I have opted to avoid the question what to do with

        0,1,2,4,6,8

should that be

        0 2 1
        4 8 2

or what.... pending a cleaner RFP/RFQ....

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to