Say I’ve got the following dictionary of functions that I want to calculate on a table
q)t:(a:10?aa
bbcc;b:10?10;c:10?10f) q)d:
avdv
ma!((avg;c);(dev;
b);(mavg;;
c))
av and
dv are easy
q)![t;();{x!x}(),`a;-1_ d]
But I want to be able to apply the projection of `ma dynamically. I can get what I want by creating the projection in a query - something like
update ma:(first ma)[4]by a from update ma:mavg[;c]by a from t
but I’d like to do this in the functional form.
The projection of ma appears to pass a null as the first argument.
q)last parse"update ma:mavg[;c]by a from t"
ma| k){msum[x;0.0^y]%mcount[x;y]} :: `c
but when I attempt to use this in the functional form it doesn’t seem to work :
![t;();{x!x}(),a;enlist[
ma]!enlist(mavg;::;`c)]
and duly gives me a 'type error on the null
Am I approaching this in the wrong way? Is there a better way?