title: Scala - Merge two lists of tuples by common elements
body: <p>How to merge two lists of tuples that <em>simulates</em> Chasles' Relation? </p>
  
  <p><strong>(a, b), (b, c) => (a, c)</strong></p>
  
  <p>Here is an example:</p>
  
  <pre><code>val l1 = List(("Dan", "b"), ("Dan","a"), ("Bart", "c"))
  val l2 = List(("a", "1"), ("c", "1"), ("b", "3"), ("a", "2"))
  </code></pre>
  
  <p>Expected result would be:</p>
  
  <pre><code>val result = List(("Dan", "3"), ("Dan", "1"), ("Dan", "2"), ("Bart", "1"))
  </code></pre>