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.
- @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.
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.
Copyright (C) 2010 by Salvador Fandiño (email@example.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.