set namespace on .q file

https://learninghub.kx.com/forums/topic/set-namespace-on-q-file

hi, on a .q file, how can I set the namespace (e.g. ns), so that I do not have to specific the namespace every time when defining a function?

Instead of:

.ns.fn1:{}

.ns.fn2:{}

 

Can we have something like:

(set namespace ns)

fn1:{}

fn2:{}

Yes this can be done as follows

// Move into namespace d .ns fn1:{} fn2:{} // Move out of namespace d .

Yes, this is possible using the system command “d”. See here for more info: https://code.kx.com/q/basics/syscmds/#d-directory

 

q)d .ns q.ns)fn1:fn2:{}

q)d .

q).ns | :: fn2| {} fn1| {}