title: Cartesian product two lists
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/482866/f-cross-product-of-two-lists">F# - cross product of two lists</a><br>
    <a href="https://stackoverflow.com/questions/6198168/projecting-a-list-of-lists-efficiently-in-f">Projecting a list of lists efficiently in F#</a>  </p>
  </blockquote>
  
  
  
  <p>I have a function that takes two integer lists and returns a single list with all the cartesian products. I think i have the correct idea but not the right implementation. Can I get some pointers?</p>
  
  <pre><code>let rec cartesian = function
   | ([],[]) -&gt; []
   | (xs,[]) -&gt; []
   | ([],ys) -&gt; []
   | (x::xs,ys) -&gt;   List.map(fun y -&gt; (x,y)::[]) cartesian (xs,ys) 
  </code></pre>