title: Is it possible to use high order functions to amalgamate duplicate objects in an array?
body: <p>I have an array of objects, each object has a name and a quantity. I want to scan through the array and if any objects have the same name, to reduce to one single object with the total quantity of all those objects that have been merged.</p>
  
  <pre><code>struct AnObject {
      var name: String
      var quantity: UInt
  }
  
  var anArray = [AnObject(name: "one", quantity: 2),
                  AnObject(name: "two", quantity: 2),
                  AnObject(name: "one", quantity: 2),
                  AnObject(name: "one", quantity: 2),
                  AnObject(name: "two", quantity: 2)]
  
  // something like:     
  return reduce(anArray,(),{ /* some magic */})
  
  // should return [{"one":6},{"two",4}]
  </code></pre>
  
  <p>This can be done using a cumbersome for loop creating a new array but is there a more 'functional' way of doing it with high order functions like .filter, .reduce or even .map?</p>