title: How can I reduce a list by or-ing all its elements together?
body: <p>If I'm not mistaken, Linq's <code>.Aggregate</code> works like <code>reduce()</code> in other languages, doesn't it?</p>
  
  <p>Anyway, I'm trying this:</p>
  
  <pre><code>var tags = new[] { "a", "b", "c", ... };
  tag.Rule = tags.Aggregate((x, y) =&gt; ToTerm(x) | y);
  </code></pre>
  
  <p>But it won't compile because the return type of my lambda has to be a string. So how can I get this to work?</p>
  
  <p>I know it looks funny, because of the types (this is going into an Irony grammar), but all you really need to know that <code>ToTerm()</code> returns a <code>KeyTerm</code>, and <code>KeyTerms</code> can be or'd together to make a <code>BnfExpression</code>, which is what tag.Rule is expecting.</p>