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 Select and Cases while maintaining convenient notation. It is particularly useful in conjunction with Listable functions.

See the included notebook file for usage examples.



Simply drop BoolEval.m in the directory opened by

SystemOpen@FileNameJoin[{$UserBaseDirectory, "Applications"}]

then load it as

<< BoolEval`

Possible issues

Within BoolEval, the meaning of relational operators (>, >=, ==, etc.) and logical operators (&&, ||, !) is overloaded. Avoid using program code within BoolEval itself.

Thus the following will fail (without errors):

 Select[Range[100], OddQ[#] || # == 2 &] < 10

Instead compute the array first:

array = Select[Range[100], OddQ[#] || # == 2 &];

And use it in BoolEval afterwards:

BoolEval[array < 10]

This slight inconvenience is necessitated by the tendency of Greater, Less, etc. to trigger unpacking.


Feedback is welcome at szhorvat at