On Fri, 1 Feb 2002 21:28:41 +0900, Nobumi Iyanaga wrote:

>I am working on making an index of a book.  I have many numbers that I must 
>sort in ascendent order -- but indices in books require a special format. 
>Say that I have a list of number like this:
>
>(15, 18, 30, 31, 42, 45, 46, 47)
>
>the output must be:
>
>15, 18, 30-31, 42, 45-47
>
>I.e. consecutive numbers must be joined with "-".  I cannot figure out how 
>to do it in Perl script.  I would appreciate very much if someone could 
>give me a clue.

This question has already been asked a few times on comp.lang.perl.misc.
Yes, even by me.


<http://groups.google.com/groups?threadm=37bf9c06.1651265%40news.skynet.be>

I don't know if Bit::Vector is available for MacPerl... Oh, it looks
like it: <http://dev.macperl.org/cgi-bin/mmp.plx/>. Do take a look at
it, especially to the method "to_Enum".

In case you're wondering: a "bitvector" is an array of bits. Perl has
the primitive vec() for it built-in, disguising a bitvector as a string;
but this module offers a few extra's, in the form of methods.

-- 
        Bart.

Reply via email to