title: F# arrays and match pattern
body: <p>I'm trying yo learn F# and arrays with recursion. I have solved summarizing an array with recursion now I'm trying to do the same thing except this time with match pattern but I can't get it to work help.</p>
  
  <pre><code>let myArray = Array.create 5 0
  
  myArray.[0] &lt;- 0
  myArray.[1] &lt;- 1
  myArray.[2] &lt;- 2
  myArray.[3] &lt;- 3
  myArray.[4] &lt;- 4
  
  let rec sum (arr : int array) counter =
      if counter = 0 then 0
      else arr.[counter] + sum arr (counter - 1)
  
  ////////////////////////////////////////////////
  // Can't get this to work.
  
  let rec sum1 (arr : int array) counter =
      match arr with
      | [||] -&gt; printfn "0"
      | arr -&gt; arr.[counter] + sum arr (counter - 1)  
  </code></pre>