Re: Is there any way to functionally get the name of an individual

Assuming the var you’re looking for (‘a’ in this case) lives in the root namespace, and there aren’t two variables in the root namespace with the same value, you could search the root namespace for the variable as follows:

q)a:30

q)findVarInRoot:{where v!get’[v:key`.]~'x}

q)findVarInRoot a

,`a

q)findVarInRoot 30

,`a

q)findVarInRoot 60

`symbol$()

If you want to get a variable of the same name in context ‘g’:

q).g.a:“an integer”

q){.g findVarInRoot x} 30

“an integer”

Mohammad Noor

Ah ok, so this sort of needs to work for a variable in any namespace, and there could very well be two variables with the same value in the namespace.

I need this to gather the contents of some dictionary/variable .d and the values of .g.d from just .d as a variable. The two .d and .g.d will then be sent over a handle to a Java program which will construct a GUI for the data in .d from the options given in .g.d.

If there’s no easy way to programmatically get the name of a dictionary/variable, then I’l probably just send .d over the handle and then query the q server from the java program for .g.d