NAME
Bit::Grep - select elements from an array using a bit vector
SYNOPSIS
use Bit::Grep qw(bg_grep bg_sum);
my @selected = bg_grep $vec, @array;
my $sum = bg_sum $vec, @array
DESCRIPTION
This module provides some functions to select elements from and array using a bit vector.
API
- @selected = bg_grep $vec, @array
-
Selects elements from @array using bit vector $vec as the selector.
It is equivalent to
@selected = @array[grep vec($vec, $_, 1), 0..$#array];
- $sum = bg_sum $vec, @array
-
Returns the sum of the elements of @array selected by $vec.
- $sum = bg_avg $vec, @array
-
Returns the average of the elements of @array selected by $vec.
- ($count, $sum) = bg_count_and_sum $vec, @array
-
Returns the number of elements selected and their sum
- ($count, $sum, $sum2) = bg_count_and_sum $vec, @array
-
Returns the number of elements selected, their sum and the sum of their squares.
BUGS AND SUPPORT
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.
SEE ALSO
"vec" in perlfunc, "grep" in perlfunc, "sum" in List::Util.
COPYRIGHT AND LICENSE
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.