title: How to transform a list of numbers into a list of ranges of consecutive numbers
body: <p>I'm generating a list of numbers:</p>
  
  <pre><code>[1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19]
  </code></pre>
  
  <p>Note how some numbers are missing (in this case, every 5th number). I want to transform consecutive numbers into ranges, delimited by a dash.</p>
  
  <p>In the above case, I'd like the output to be</p>
  
  <pre><code>"1-4,6-9,11-14,16-20"
  </code></pre>
  
  <p>How can I go about solving this problem?</p>