title: Generating subset of multi-dimensional array
body: <p>I'm playing with F# classes by converting one of my existing .NET classes to F#.  The class works with a 2-dimensional array of 8 columns and 10000 rows of 0-1024 integer data</p>
  
  <p>My getPar methods returns a single column of data.  My gatePar takes a lo and hi predicate and returns a 2-tuple of boolean and index.  The tuple tells me if any given index falls within the lo and hi value.</p>
  
  <p>What would be the best way to use the gatePar tuple to return the entire array of true values or values within a limit based upon a single column?</p>
  
  <p>I'm looking to generate a subset of my dataArray with 8 columns and 10000 or less rows.</p>
  
  <p>My code:</p>
  
  <pre><code>let mutable lo = int16(300)
  let mutable hi = int16(700)
  
  member x.SetLow low = lo &lt;- int16(low)
  member x.SetHigh high = hi &lt;- int16(high)
  
  member x.Par =
      x.dataArray.[0..0,0..] 
  
  member x.flatten (dataArray:'a[,]) = dataArray |&gt; Seq.cast&lt;'a&gt;
  
  member x.getRow r (dataArray:_[,]) =
      x.flatten dataArray.[*,r..r] |&gt; Seq.toArray  
  
  member x.getColumn c (dataArray:_[,]) =
      x.flatten dataArray.[*,c..c] |&gt; Seq.toArray
  
  member x.getPar c  =
      x.flatten x.dataArray.[c..c,*] |&gt; Seq.toArray
  
  member x.gatePar c =
      x.flatten x.dataArray.[c..c,*] 
      |&gt; Seq.mapi (fun i x -&gt; x &gt; lo &amp;&amp; x &lt; hi, i)
      |&gt; Seq.toArray
  </code></pre>
  
  <p>Calling it from VB.NET:</p>
  
  <pre class="lang-vb prettyprint-override"><code>inst.SetLow(200)
  inst.SetHigh(500)
  Dim results = inst.gatePar(2)
  </code></pre>