title: Reduce nested array to formatted string
body: <p>I want to reduce this nested array:</p>
  
  <pre><code>const list = ['Map&lt;%s,%s&gt;', ['string', 'Map&lt;%s,%s&gt;', ['string', 'boolean']]];
  </code></pre>
  
  <p>so that list becomes:</p>
  
  <pre><code>'Map&lt;string,Map&lt;string,boolean&gt;&gt;'
  </code></pre>
  
  <p>Here is a start, but the recusion is really confusing to me:</p>
  
  <pre><code>const util = require('util');
  
  const reduceToString = function(l){
    return l.reduceRight((a,b) =&gt; {
      if(Array.isArray(a)){
        return reduceToString(a);
      }
  
      return util.format(b, a);
  
    });
  };
  
  
  console.log(reduce(list));
  </code></pre>
  
  <p><em>For better understanding to see how this needs to work generically, this input:</em></p>
  
  <pre><code>const list = ['Map&lt;%s,%s,%s&gt;', ['string', 'Map&lt;%s,%s&gt;', ['string', 'boolean'], 'number']];
  </code></pre>
  
  <p>should yield:</p>
  
  <pre><code>'Map&lt;string,Map&lt;string,boolean&gt;,number&gt;'
  </code></pre>
  
  <p>The <strong>general rule</strong> is: any array to the right of a string, should be interpolated into the string, and the reduceToString function should always return a string.</p>