List::MoreUtils has a function indexes which does that:
indexes BLOCK LIST
Evaluates BLOCK for each element in LIST (assigned to $_) and returns a list of the indices of those elements for which BLOCK returned a true value. This is just like grep only that it returns indices instead of values:
So you could write
@a[ indexes { $_ > 1 } @b ]Not quite as nice as in Matlab but close.
In reply to Re^3: Boolean array indexing
by hdb
in thread Boolean array indexing
by johnmillerflorida
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |