title: How to write a function that returns an array of indices of values in array x in array y?
body: <p>I am trying to write an efficient algorithm that will effectively let me merge data sets (like a sql join).  I think I need to use Array.tryFindIndex, but the syntax has me lost.</p>
  
  <p>Based on the data below, I am calling arrX my "host" array, and want to return an int array that has its length, and tells me the positions of each of its elements in arrY (returning -1 if its not in there). (Once I know these indices I can then use them on arrays of data that of length arrY.length)</p>
  
  <pre><code>let arrX= [|"A";"B";"C";"D";"E";"F"|]
  let arrY = [|"E";"A";"C"|];
  
  
  let desiredIndices = [|1; -1; 2; -1; 0; -1|]
  </code></pre>
  
  <p>It looks like I need to use an option type somehow, and I think a mapi2 in there as well.
  Does anyone know how to get this done?  (I think it could be a very useful code snippet for people who are merging data sets from different sources)</p>
  
  <p>Thanks!</p>
  
  <pre><code>//This code does not compile, can't figure out what to do here
  let d = Array.tryFindIndex (fun x y -&gt; x = y) arrX
  </code></pre>