On Wednesday, 21 March 2012 at 20:13:37 UTC, Jesse Phillips wrote:

Note, I commented out reduce as it uses the array type instead of the calculation type. I think I'll file than as a bug. Also the reduce version would not give you a double back even if it did work, need a cast in there.

Nevermind, just needed to map

double average(string param)(Data[] x)
{
 static if (!isNumeric!(typeof(mixin("Data."~param))))
   return -1;
 else
 {
return cast(double)reduce!("a + b")(map!("a."~param)(x))/x.length;
 }
}

Reply via email to