Reference/cut

From Kx Wiki
Jump to: navigation, search

Contents

cut (cut verb)

Verb cut splits its right argument according to its left.

Syntax

R:X cut Y

cut has two slightly different behaviors, depending on its left argument:

q)4 cut til 10
0 1 2 3
4 5 6 7
8 9
q)2 4 9 cut til 10           / the first result item starts at index 2
2 3
4 5 6 7 8
,9
q)
q)2 4 4 9 cut til 10         / cuts are empty for duplicate indices
2 3
`int$()
4 5 6 7 8
,9

Remark

cut is a simple derivative of the primitive _ (drop/cut). Where the left argument is an atom, it cuts the right argument into equal sized parts, and otherwise it behaves like _. For example:

q)"abcde" _ 3                / drop element with index 3
"abce"
q)"abcde" cut 3              / cut works the same
"abce"

See also


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

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox