Reference/DotSymbol

From Kx Wiki
Revision as of 20:25, 11 April 2014 by Aaron Davies (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

. (index/apply)

All indexing and function application can be done with the verb denoted by Dot.

Everything starts from a dot. - Wassily Kandinsky

q)d:((1 2 3;4 5 6 7);(8 9;10;11 12);(13 14;15 16 17 18;19 20))
q)d . 1 2        / same as d[1;2]
11 12
q)d . 1 2 0      / same as d[1;2;0]
11
q)d . enlist 1   / same as d[1]
(8 9;10;11 12)

You can see from the examples that the ith item in the index selects from the ith level of the list. You can also see that to index at the top level only, you must use a one-item list.

Dot is particularly useful when executing functions of varying valence (argument count) under program control. Both . and @ are referred to as Index or Apply, depending on the context.

Here is an example for using functions with varying valence. Defining execFunction as {[fun;param] fun[param]} would not work.

f1: {x}
f2: {x+y}
execFunction: {[fun;param] .[fun;param] }
execFunction[f1;enlist 1] // result is 1
execFunction[f2;(1 2)] // result is 3
Warning.png . is also used for (multivalent) protected execution

See also


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

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox