Notice: This version is no longer maintained. Please use the GitHub version instead.
BoolEval is a Mathematica package that helps evaluate conditional expressions on numerical arrays, or filter numerical arrays based on conditions. Is does this without unpacking packed arrays and offers a significant speedup over
Cases while maintaining convenient notation. It is particularly useful in conjunction with
See the included notebook file for usage examples.
Simply drop BoolEval.m in the directory opened by
then load it as
BoolEval, the meaning of relational operators (
==, etc.) and logical operators (
!) is overloaded. Avoid using program code within
Thus the following will fail (without errors):
BoolEval[ Select[Range, OddQ[#] || # == 2 &] < 10 ]
Instead compute the array first:
array = Select[Range, OddQ[#] || # == 2 &];
And use it in
BoolEval[array < 10]
This slight inconvenience is necessitated by the tendency of
Less, etc. to trigger unpacking.
Feedback is welcome at
szhorvat at gmail.com.