Trying to modularise some latex table generation code, massive gold plating.
var MIDRULE = @"\\\midrule";
var a = new []{new []{"a", "b", "c"}, new []{"1", "2", "3"}, new []{"alpha", "beta", "gamma"}};
a.Dump();
a.Aggregate(
(x,y) => x.Aggregate((i,j) => i + "&" + j)
+ MIDRULE + Environment.NewLine
+ y.Aggregate((k,l)=>k+"&"+l)).Dump();
Expected result:
a&b&c\\\midrule
1&2&3\\\midrule
alpha&beta&gamma\\\midrule
Actual result:
Cannot implicitly convert type 'string' to 'string[]'
I’d like to do this with a one liner of aggregate commands if possible, can already do this in a nested loop or various other ways, I’m interested in getting to know aggregation better.
Try:
Be careful not to use
Joinfor the outer call as you wantMIDRULE + Environment.NewLineto be appended to every string including the last one.Edit:
Since you are keen to use
Aggregatehere (I wouldn’t recommend it as it is less readable and much more inefficient), try (untested):