From Kx Wiki
Jump to: navigation, search

vs (vector from scalar verb)

The vector from scalar verb performs different functions depending on its arguments. Typically, it returns an list (vector) from each atom (scalar) in its argument, or may return a list of lists from a list.


q)r:X vs Y

If Y is a string, and X is a character or string, it cuts Y using X as the delimiter, returning a list of strings:

q)"," vs "one,two,three"
q)", " vs "spring, summer, autumn, winter"
q)"|" vs "red|green||blue"

If X is 0b and Y is an integer, it returns the bit representation of Y:

q)0b vs 23173h
q)0b vs 23173

If X is 0x0 and Y is a number, it returns the internal representation of Y, with each byte in hex:

q)0x0 vs 2413h
q)0x0 vs 2413
q)0x0 vs 2413e
q)0x0 vs 2413f
q)"."sv string"h"$0x0 vs .z.a / ip address string from .z.a

If X is the back tick `, then it splits symbols on `.`, breaks file handles into directory & file parts and if y is a string it breaks into lines (cross-platform - both UNIX (\n) and DOS (\r\n) end of lines):

q)` vs `mywork.dat
q)` vs `:/home/kdb/data/mywork.dat
q)` vs "abc\ndef\nghi"
q)` vs "abc\r\ndef\r\nghi"

Since 3.4t 2015.12.13: For integer types, computes the base representation of Y in the radices X. e.g.

q)10 vs 1995
1 9 9 5
q)2 vs 9
1 0 0 1
q)24 60 60 vs 3805
1 3 25
q)"." sv string 256 vs .z.a / ip address string from .z.a

If the right argument is an integer vector then the result of x vs y is a matrix with count[x] items whose ith column (x vs y)[;i] is identical to x vs y[i]. More generally, the right argument y can be any list of integers, and each item of the result is identical to y in structure. e.g.

q)a:10 vs 1995 1996 1997
1 1 1
9 9 9
9 9 9
5 6 7
1 9 9 5
q)10 vs(1995;1996 1997)
1 1 1
9 9 9
9 9 9
5 6 7

See also

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

Personal tools