Thanks to autovivification, the direct calculation of max is unnecessary. To create an array whose final element is at the maximum position of a 1:
my @bits; $bits[$_] = 1 for @pos; for (0..($#bits-1)) { $bits[$_]=0 unless defined($bits[$_]); }
Best, beth
In reply to Re^2: sequence of positions to binary sequence
by ELISHEVA
in thread sequence of positions to binary sequence
by coldy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |