“Pick” Function in Mathematica 14.3 

Written by on October 5, 2025 in Mathematica, Programming with 0 Comments

Pick is a widely used function in Mathematica. A minor enhancement was made to this function in the recent release; it can now work directly with BitVector datastructure. In this article, let us go over these two with some examples.

Let us start with Pick first. It allows us to select from a list of elements based on some criterion. Look at these examples:

Using Pick Function

Using Pick Function

The first example selects week days based on a list of seven {True, False} elements. In the second example we use randomly generated five {0, 1} integers and use Pick to select those elements from {a, b, c, d, e} where the corresponding integer is 1 in the integer list.

The third example generates a Cyclic object based on another Cyclic object.

BitVector

BitVector is one of the several built-in data structures in Mathematica. These data structures are highly optimized in terms of space and operations.

There are standard operations that are defined on BitVector, for example, Setting, Clearing, and Inverting bits.

Using BitVector

BitVector Operations

The function “Normal[]” is convenient for converting the BitVector object to a list of {True, False} elements for easy decoding. As you can guess, “True” corresponds to “1” inside the BitVector and “False” corresponds to “0”.

We can even “visualize” the BitVector object thus:

Visualizing BitVector

Visualizing BitVector

Using BitVector with Pick

Now that we know about both Pick and BitVector, let us see how we can combine both. How do we “Pick” those elements from a list based on the contents of a BitVector? Here are some examples:

Using BitVector in Pick

Using BitVector in Pick

Being able to use a BitVector object directly with Pick, instead of converting the object to a list of Boolean values is definitely cleaner and more efficient. This enhancement in the new release of Mathematica is welcome indeed! 

Have a great weekend!

Tags: ,

About the Author

About the Author: .

Subscribe

If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *

Top