passing single k object as argument in KDB function to fill its

Hi,

I am trying to implement below functionality using KDB  C API.<o:p></o:p>

<o:p> </o:p>From command line:

<o:p></o:p>

q) t: (a: ();b: ())<o:p></o:p>

q) {[m;n] `t insert (m;n)} . (1,2)<o:p></o:p>

a b<o:p></o:p>

—<o:p></o:p>

1 2<o:p></o:p>

From the C API, here’s what worked and what did not:

<o:p></o:p>

K i = ki(1); // create 1st integer<o:p></o:p>

K j = ki(2); // create 2nd integer<o:p></o:p>

K lst = ktn(6, 2); // create a list(row) of 2 integers <o:p></o:p>

lst = ja(&lst,&i);<o:p></o:p>

lst = ja(&lst,&j);<o:p></o:p>

K r = k(conn, “{[m;n] `t insert (m;n)}”,i,j,(K)0); // works 

<o:p></o:p>

This fails: <o:p></o:p>

K(conn, "{[m;n] `t insert (m;n) } ", lst,(K)0); // fail

Is there a way to make this work through C API? 

Thanks

yes, you can do

 I i = 1;

 I j = 2;

 K lst = ktn(6, 0);

  lst = ja(&lst,&i);

  lst = ja(&lst,&j);

 k(0,“{[m;n]`t insert (m;n)} .”,lst,(K)0);

if you choose to prealloc the list to have 2 entries, fill those with

kI(lst)[0]=i;

kI(lst)[1]=j;