flies has asked for the wisdom of the Perl Monks concerning the following question:
i want to use a statistics::basic::computedvector::set_filter, but the filter i want to use is an array of 1's and 0's. is this possible?
here's what I want to do:
my $v1 = vector(1,2,3,4,5); my @filter = qw(1 0 0 1 1); my $cv = computed($v1); $cv->set_filter(@filter);
I tried the following:
my $v1 = vector(1,2,3,4,5); my $compV1 = computed($v1); my @filter = (1) x $compV1->query_size(); $filter[-1] = 0; say $compV1; $compV1-> set_filter( sub { grep { $filter[$_] } 0..$#_ } ); say $compV1;
but this prints
what should I do?[1, 2, 3, 5, 7] [0, 1, 2, 3]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: statistics basic - filter vector according to array
by ikegami (Patriarch) on Mar 09, 2011 at 16:47 UTC | |
by flies (Novice) on Mar 09, 2011 at 20:59 UTC |