Is there a command to sum duplicate entries from an input data file in an "initializations from..." block?
For example, if I have a file input.dat:
and my Mosel code contains:
Materials: set of string
Cost: array(Materials) of real
initializations from "input.dat"
forall(m in Materials) writeln(m + " costs: " + Cost(m))
I'd like to see that Material "A" costs 3 ( = 1+2 ), but will instead see that it costs 2 (only the last duplicate value in the data file overwrites all previous duplicates). I understand that this is intended behavior, and that I could seek to do the summation on my data source, but is there an easy way to do this in Mosel?