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

**URL:** https://forum.kx.com/t/passing-single-k-object-as-argument-in-kdb-function-to-fill-its/8504
**Category:** Community Support
**Tags:** kdb-and-q
**Created:** [November 18, 2013, 3:28pm UTC](https://forum.kx.com/t/passing-single-k-object-as-argument-in-kdb-function-to-fill-its/8504 "2013-11-18T15:28:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![abhi\_california](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@abhi\_california](https://forum.kx.com/u/abhi_california)
#### Post date: [November 18, 2013, 3:28pm UTC](https://forum.kx.com/t/passing-single-k-object-as-argument-in-kdb-function-to-fill-its/8504/1 "2013-11-18T15:28:00Z")

</div>

Hi,

I am trying to implement below functionality using KDB &nbsp;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&nbsp;

\<o:p\>\</o:p\>

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

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

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

Thanks

---

<div class="post-metadata">

### Author: ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)
#### Post date: [November 18, 2013, 3:49pm UTC](https://forum.kx.com/t/passing-single-k-object-as-argument-in-kdb-function-to-fill-its/8504/2 "2013-11-18T15:49:00Z")

</div>

yes, you can do

&nbsp;I i = 1;

&nbsp;I j = 2;

&nbsp;K lst = ktn(6, 0);

&nbsp; lst = ja(&lst,&i);

&nbsp; lst = ja(&lst,&j);

&nbsp;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;
