Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

wj failed for columns' sum product

I have below code and I want to do sumproduct. When I do sum(weight) at wj, it works. But if I do sum(weight*price) at wj, it failed. How can I do the sumproduct? Thanks!!

t:([]sym:3#`ibm;time:10:01:01 10:01:04 10:01:08;price:100 101 105);

price:101 103 103 104 104 107 108 107 108;
weight:98 99 102 103 103 104 106 106 107;
q:([]sym:`ibm; time:10:01:01+til 9; price:price; weight:weight);
f:`sym`time;
w:-2 1+\:t.time;

wj[w;f;t;(q;(sum;`price);(sum;`weight))]; // OK

wj[w;f;t;(q;(sum;`price);(sum;(*;`price;`weight)))]; // failed

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Based on the documentation multi-column argumnents can be passed (since 3.6 2018.12.24), but it does not seem that expressions can be passed. Based on that you should be able to rewrite your calculation as a lambda that accepts multiple columns.

wj[w;f;t;(q;(sum;`price);({sum x*y};`price;`weight))]
sym time     price weight
-------------------------
ibm 10:01:01 204   20095
ibm 10:01:04 414   42127
ibm 10:01:08 430   45474
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading