There's not much to add here. Of course I'm able to get it done somehow with an imperative coding style, but I'm curious how this can be solved nicely.
def this( arguments: Seq[(String, String)], merges: Seq[(String, String)]) = this
{
val metadata: Seq[Attribute] = ( arguments ++ merges ).groupBy( _._1 ).map
{
case (key, value) => Attribute( None, key, Text( value.map( _._2 ).mkString( " " ) ), Null )
}
var result: MetaData = Null
for( m <- metadata ) result = result.append( m )
result
}