Hot answers tagged


MemberQ's operator form seems to be useful for searching for the same value in different lists. If you need to search for different values in the same list many times, I would build an association that has the list elements as keys, and then use Lookup. For example, list = RandomInteger[10, 10] (* {3, 8, 9, 3, 8, 3, 5, 8, 9, 5} *) asc = AssociationMap[...


I'm going to demonstrate Nearest, even though NearestFunction is about 10-20 times slower than Lookup. On the other hand Nearest is faster at creating the underlying data structure than AssociationMap/PositionIndex. The use of Lookup seems clearer than this indirect use of Nearest, so the interest may be only academic. list = RandomInteger[10^9, 10^6]; ...


Using george2079's suggestion, the code can be tweaked to ExactExpressionQ[expr_] := FreeQ[expr, _Real|_Complex?InexactNumberQ, {-1}] for better performance.

Only top voted, non community-wiki answers of a minimum length are eligible