key¶
key x key[x]
Key of a dictionary¶
Where x is a dictionary (or the name of one), returns its key.
A namespace is a dictionary.
q)key `.
`D`daily`depth`mas`sym`date`nbbo...
q)key `.q
``neg`not`null`string`reciprocal`floor`ceiling`signum`mod`xbar`xlog`and`or`ea..
So is the default namespace.
q)key ` / namespaces in the default namespace
`q`Q`h`o`util`rx
q)key `. / objects in the default namespace
`a`s`b`t`deltas0`x`c
Keys of a keyed table¶
Where x is a keyed table (or the name of one), returns its key column/s.
Files in a folder¶
Where x is a directory handle returns a list of objects in the directory, sorted ascending.
To select particular files, use like
Whether a folder exists¶
An empty folder returns an empty symbol vector; a non-existent folder returns an empty general list.
Whether a file exists¶
Where x is a file handle, returns the descriptor if the file exists, otherwise an empty list.
Note that
- an empty directory returns an empty symbol vector
- a non-existent directory returns an empty general list
q)\ls foo
ls: cannot access foo: No such file or directory
'os
q)()~key`:foo
1b
q)\mkdir foo
q)key`:foo
`symbol$()
Whether a name is defined¶
Where x is a symbol atom that is not a file or directory descriptor, nor the name of a dictionary or keyed table, returns the original symbol if a variable of that name exists, otherwise an empty list. The name is interpreted relative to the current context if not fully qualified.
q)()~key`a /now you don't see it
1b
q)a:1
q)key`a /now you see it
`a
q)\d .foo
q.foo)key`a /now you don't
q.foo)a:1 2!3 4
q.foo)key`a /this one has keys
1 2
q.foo)key`.foo.a /fully qualified name
1 2
q.foo)key`..a /fully qualified name
`..a
q.foo)\d .
q)key`a
`a
q)key`.foo.a
1 2
q)key`..a
`..a
Target of a foreign key¶
Where x is a foreign-key column returns the name of the foreign-key table.
Type of a vector¶
Where x is a vector returns the name of its type as a symbol.
q)key each ("abc";101b;1 2 3h;1 2 3i;1 2 3;1 2 3f)
`char`boolean`short`int`long`float
q)key 0#5
`long
Enumerator of a list¶
Where x is an enumerated list returns the name of the enumerating list.
til¶
Where x is a non-negative integer returns the same result as til.