| Bit::Grep - select elements from an array using a bit vector |
Bit::Grep - select elements from an array using a bit vector
use Bit::Grep qw(bg_grep bg_sum);
my @selected = bg_grep $vec, @array; my $sum = bg_sum $vec, @array
This module provides some functions to select elements from and array using a bit vector.
Selects elements from @array using bit vector $vec as the selector.
It is equivalent to
@selected = @array[grep vec($vec, $_, 1), 0..$#array];
Returns the sum of the elements of @array selected by $vec.
Returns the average of the elements of @array selected by $vec.
Returns the number of elements selected and their sum
Returns the number of elements selected, their sum and the sum of their squares.
If you find any bug on this module, please send a bug request through the CPAN bug tracker https://rt.cpan.org/Dist/Display.html?Queue=Language-Prolog-Yaswi
Feedback or requests for new features are also welcome.
perlfunc/vec, perlfunc/grep, sum in the List::Util manpage.
Copyright (C) 2010 by Salvador Fandiño (sfandino@yahoo.com)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10 or, at your option, any later version of Perl 5 you may have available.
| Bit::Grep - select elements from an array using a bit vector |