my @pos = (2,4,6,9); my $bin = 0; for (my $i = 0; $i < scalar @pos; $i++) { $bin |= 1 << $pos[$i]; } # Printing out the result is left as a follow-on exercise...
--
use JAPH;
print JAPH::asString();
In reply to Re: sequence of positions to binary sequence
by wol
in thread sequence of positions to binary sequence
by coldy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |