Passing list of values to nested function in kdb

73 Views Asked by At

Function:

.terry.func:{
 tab:([]`a`b`c;b:1 2 3;c:`MSFT`GLE`APPLE);
 list:((`a,'1);(`b,'2));
 .terry.func2:{[t;x;y]select from t where a = x,b = y} [tab;;] each list;
 :.terry.func2
 }

The list I will actually extract from another table and will concatenate by ,'

However, I am not sure how to make this function work

2

There are 2 best solutions below

3
rianoc On

This may be what you are after:

.terry.func:{
 tab:([] a:`a`b`c;b:1 2 3;c:`MSFT`GLE`APPLE);
 list:((`a;1);(`b;2));
 {[t;x;y]select from t where a = x,b = y}[tab](.)/:list
  };
q)raze .terry.func[]
a b c   
--------
a 1 MSFT
b 2 GLE 

0
user20349 On

Why not generate a table out of list?

.terry.func:{
 tab:([]a:`a`b`c;b:1 2 3;c:`MSFT`GLE`APPLE);
 list:`a`b!flip ((`a;1);(`b;2));
 select from tab where ([]a;b) in list
 }