title: Erlang bit indexing
body: <p>I am currently trying to learn erlang and what I am trying to do is to perform an operation on specific indices of an array stored in a bit array or int.  If there is a 0 in a position, the index into the array at that position is not used.</p>
  
  <p>So envision the following:</p>
  
  <pre><code>Example the array is: [1, 3, 5, 42, 23]
  My bit array is: 21 = 10101 in binary
  so I'm using indicies 1,3,5
  so I'm calling a function on [1, 5, 23]
  </code></pre>
  
  <p>my function is of the form</p>
  
  <pre><code>my_function(Array, BitArray) -&gt;
      SubArray = get_subarray_from_bitarray(Array, BitArray),
      process_subarray(SubArray).
  </code></pre>
  
  <p>And I need help with the get_subarray_from_bitarray().  I know erlang has special syntax around bit strings (something like &lt;&lt;>>) so is there an efficient way of indexing into the bit array to get the indicies?</p>