title: Intersect all possible combinations of list elements
body: <p>I have a list of vectors:</p>
  
  <pre><code>&gt; l &lt;- list(A=c("one", "two", "three", "four"), B=c("one", "two"), C=c("two", "four", "five", "six"), D=c("six", "seven"))
  
  &gt; l
  $A
  [1] "one"   "two"   "three" "four"
  
  $B
  [1] "one" "two"
  
  $C
  [1] "two"  "four" "five" "six"
  
  $D
  [1] "six"   "seven"
  </code></pre>
  
  <p>I would like to <strong>calculate the length of the overlap between all possible pairwise combinations of the list elements</strong>, i.e. (the format of the result doesn't matter):</p>
  
  <pre><code>AintB 2
  AintC 2
  AintD 0
  BintC 1
  BintD 0
  CintD 1
  </code></pre>
  
  <hr>
  
  <p>I know <code>combn(x, 2)</code> can be used to get a matrix of all possible pairwise combinations in a vector and that <code>length(intersect(a, b))</code> would give me the length of the overlap of two vectors, but I can't think of a way to put the two things together.</p>
  
  <p>Any help is much appreciated! Thanks.</p>