Bob Showalter <[EMAIL PROTECTED]> writes:

> Here's what I came up with. I wonder if this can be made shorter:
> 
>  @list = (9,11,12,13,14,23,25,26,27,50);
> 
>  while ($f = shift @list) {
>      print $f;
>      last unless @list;
>      print(','), next unless $list[0] == ++$f;
>      print "-";
>      shift @list while @list > 1 && $list[1] == ++$f;
>  }
> 
> Output:
> 
>  9,11-14,23,25-27,50

Beautiful!

This is a great example of why I love Perl - it reads how I
think.

We call them "computer" languages, but (lately) they have
more to do with how *we* think than how *computers* operate.
I think they should be called "thinking languages" because
they structure our thinking.  Boole came up with such a
structure long before it could be executed by cams, tubes,
or silicon.

-- 
Michael R. Wolf
    All mammals learn by playing!
       [EMAIL PROTECTED]


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

Reply via email to