Reference/Brackets

From Kx Wiki
Revision as of 17:50, 16 August 2012 by Michael Gottlieb (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

[] (block/arguments)

block

Some expressions, such as the if-else, use single expressions as parameters. However, it is possible to use multiple expressions in the place of one by placing several expressions, separated by semicolons, inside [] brackets:

q)$[1b;b:"tr";b,"ue";"false"]   / invalid
'rank
q)$[1b;[b:"tr";b,"ue"];"false"]
"true"

arguments

The arguments of a function can be included within brackets, separated by semicolons. This syntax is sometimes necessary, and always allowed.

q)$[`int;0xff]      / equivalent to `int$0xff, note order of arguments
255
q)+/[1 2 3]         / cannot write +/1 2 3 directly
6
q){x+y+z}[1;2;3]
6
q)f:+[3;]           / leave out an argument to create a projected function
q)f 4
7

For a complete list of functions, see the kdb+ Function Reference.

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox