title: transpose of a list of lists
body: <p>I'm trying to make a recursive function to get the transpose of a list of lists, <code>n x p</code> to <code>p x n</code>. But i'm unable to do so. I've been able to make a function to transpose a <code>3 x n</code> list of lists to an <code>n x 3</code> one:</p>
  
  <pre><code>let rec drop1 list=
      [(match (List.nth list 0) with [] -&gt; [] | a::b -&gt; b);
       (match (List.nth list 1) with [] -&gt; [] | a::b -&gt; b);
       (match (List.nth list 2) with [] -&gt; [] | a::b -&gt; b);]
  
  let rec transpose list=
      if List.length (List.nth list 0) == 0 then []
      else [(match (List.nth list 0) with [] -&gt; 0 | a::b -&gt; a);
            (match (List.nth list 1) with [] -&gt; 0 | a::b -&gt; a);
            (match (List.nth list 2) with [] -&gt; 0 | a::b -&gt; a)]
           :: transpose (drop1 list)
  </code></pre>
  
  <p>But I'm not able to generalize it. I'm surely thinking in the wrong direction. Is this generalizable? Is there a better solution? Please help.</p>