in reply to sequence of positions to binary sequence
#!/usr/bin/perl use strict; my @pos = qw( 2 4 6 9 ); my @bin; for (my $i = 0; $i < $pos[-1] + 1; $i++ ) { my $counter = 0; $counter = 1 if ( grep /$i/, @pos); push( @bin, $counter ); } print join ",", @bin;
|
|---|