Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have some large (multiple million bits) bit vectors, and I'd like to run length encode them to save storage.
Given the input: my $bv = pack 'N', 0x01020304; I'd like to get out an array
-1, 9, -1, 6, -2, 8, -1, 5
Where negative counts represent set bits and positive counts clear bits.
Searches for Perl and run length encoding all seem to turn up the rosetta stone thing of RLE strings: '"wwwbbbw" => 'w3b3w1' using regex.
I know I need to use vec(), but I keep getting lost in the state changes and end up with huge nest of ifs and garbage output.
Any help appreciated.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Run length encode a bit vector
by GrandFather (Saint) on Jan 05, 2012 at 07:45 UTC | |
| |
Re: Run length encode a bit vector
by johngg (Canon) on Jan 05, 2012 at 10:59 UTC | |
by Anonymous Monk on Jan 05, 2012 at 12:24 UTC | |
by AnomalousMonk (Archbishop) on Jan 05, 2012 at 13:53 UTC | |
by Anonymous Monk on Jan 05, 2012 at 14:28 UTC | |
Re: Run length encode a bit vector
by TJPride (Pilgrim) on Jan 05, 2012 at 07:57 UTC | |
by ikegami (Patriarch) on Jan 05, 2012 at 19:28 UTC | |
by TJPride (Pilgrim) on Jan 05, 2012 at 20:42 UTC | |
by ikegami (Patriarch) on Jan 05, 2012 at 20:59 UTC | |
Re: Run length encode a bit vector
by AnomalousMonk (Archbishop) on Jan 05, 2012 at 14:04 UTC | |
Re: Run length encode a bit vector
by BrowserUk (Patriarch) on Jan 05, 2012 at 16:02 UTC | |
Re: Run length encode a bit vector
by johngg (Canon) on Jan 05, 2012 at 23:46 UTC | |
by Anonymous Monk on Jan 06, 2012 at 00:13 UTC | |
Re: Run length encode a bit vector
by sundialsvc4 (Abbot) on Jan 06, 2012 at 14:12 UTC |
Back to
Seekers of Perl Wisdom