Assign a table inside a function

Hi,

I have a function that performs some calculation on a table and return the result. It all seems fine.

I have to write another function that will accept the output table name where we will write the same data rather than returning it to caller. Because it is a function, i am not able to use “value” function as inner table is not global.

Is there some way i can assign data to a table?

I think it is

tableName set data

where data can be any type

Hi VIkas,<o:p></o:p>

<o:p> </o:p>

there are 2  ways to do it:<o:p></o:p>

<o:p> </o:p>

setme1:{tmp:: 1 2 3 4 }<o:p></o:p>

<o:p> </o:p>

setme2:{`tmp2 set 1 2 3 4}<o:p></o:p>

<o:p> </o:p>

HTH,<o:p></o:p>

<o:p> </o:p>

Kim<o:p></o:p>

<o:p> </o:p>

Von: personal-kdbplus@googlegroups.com [mailto:personal-kdbplus@googlegroups.com] Im Auftrag von Vikas Agarwal
Gesendet: Freitag, 9. Mai 2014 11:10
An: personal-kdbplus@googlegroups.com
Betreff: [personal kdb+] Re: Assign a table inside a function<o:p></o:p>

<o:p> </o:p>

I think it is<o:p></o:p>

<o:p> </o:p>

tableName set data<o:p></o:p>

<o:p> </o:p>

where data can be any type<o:p></o:p>

Thanks Kim for reply. I think i was not clearer in my question.

suppose a variable tmp is having following value. and tmp will be a parameter to a function. I dont have to set tmp into a function. that can be easily done. But i have to set the value in tmp to something.

tmp:`vikas

;{x set (1 2 3 4)}[tmp]

now in the above code. vikas variable will be set to 1 2 3 4.

Reference it by name:

q)tmp

`vikas

{x set (1 2 3 4)}[`tmp]

q)tmp

1 2 3 4

Thanks,

Sean

Sean, 

I did not want to set the tmp variable value. But i want to set the value inside temp to something.

so slight changes to your example:

q)tmp:`vikas

q)tmp

`vikas

q){x set (1 2 3 4)}[tmp]

`vikas

q)tmp

`vikas

q)vikas

1 2 3 4j