| | Bitstring vector to list conversion in Perl5 Todd Lehman
| | | Anyone know of a super-efficient way in Perl5 to convert a sparse bitstring vector to a list of integer-offset values (just the 1-bits) in Perl5? That is, if you had some $v that was created like so: my $v; my @n = (...some sorted sparse list of (...) (24 years ago, 3-Jan-01, to lugnet.off-topic.geek)
| | | | | | | | Re: Bitstring vector to list conversion in Perl5 Dan Boger
| | | | | (...) well, I can think of several ways of doing it, but since $v might be millions of bits long, we don't really want to get the full list in memory ever. So I guess the simplest way would be to run through the vector, indexing the 1s: (...) (24 years ago, 3-Jan-01, to lugnet.off-topic.geek)
| | | | | | | | | | | | Re: Bitstring vector to list conversion in Perl5 Todd Lehman
| | | | | (...) $veclength = length($v) * 8; It isn't precise, but it's fast -- and a few bits of slop would be perfectly OK here since the slop would be 0-bits. :-) (...) Well, plus, map{} is also almost always slower than looping (especially with use (...) (24 years ago, 4-Jan-01, to lugnet.off-topic.geek)
| | | | | | |