title: F# sum of a list of lists
body: <p>I created my own datatype And I'm trying to create the sum of all the numbers in that datatype which is a list of lists.  I don't want to use any F# libraries</p>
  
  <p>My datatype</p>
  
  <pre><code>type elist = A | L of int * elist
  </code></pre>
  
  <p>I'm a beginner in F# and trying to grasp my head on it.  I want to do this recursively.  My thinking going into it is to traverse to the end of the list and start an sum and go back to the front and add each one.  </p>
  
  <p>example:</p>
  
  <pre><code>let l = L(4, L(3, L(6, L(3, A))))
  </code></pre>
  
  <p>that should return</p>
  
  <pre><code>val it : int 16
  </code></pre>
  
  <p>Here's my code and I know it is wrong:  </p>
  
  <pre><code>let rec sum l = 
     let a = 0
     match l with
     | A -&gt; 0
     | L(head,A) -&gt; head 
     | L(head,tail) -&gt; sum tail + a
  </code></pre>