Skip to content

vs

“Vector from scalar”

  • partition a list
  • encode a vector from an atom

Syntax: x vs y,vs[x;y]

Partition

String by char

Where x is a char atom or string, and y is a string, returns a list of strings: y cut using x as the delimiter.

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

String by linebreak

Where x is the empty symbol `, and y is a string, returns as a list of strings y partitioned on embedded line terminators into lines. (Recognizes both Unix \n and Windows \r\n terminators).

q)\` vs "abc\ndef\nghi"
"abc"
"def"
"ghi"
q)\` vs "abc\r\ndef\r\nghi"
"abc"
"def"
"ghi"

Symbol by dot

Where x is the empty symbol `, and y is a symbol, returns as a symbol vector y split on `.`.

q)\` vs \`mywork.dat 
\`mywork\`dat

File handle

Where x is the empty symbol `, and y is a file handle, returns as a symbol vector y split into directory and file parts.

q)\` vs \`:/home/kdb/data/mywork.dat
\`:/home/kdb/data\`mywork.dat

sv join

Encode

Bit representation

Where x is 0b and y is an integer, returns the bit representation of y.

q)0b vs 23173h
0101101010000101b
q)0b vs 23173
00000000000000000101101010000101b

Byte representation

Where x is 0x0 and y is a number, returns the internal representation of y, with each byte in hex.

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

Base-x representation

Where x and y are integer, the result is the representation of y in base x. (Since V3.4t 2015.12.13.)

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
"192.168.1.213"

Where y is an integer vector the result is a matrix with count[x] items whose i-th column (x vs y)[;i] is identical to x vs y[i]. More generally, y can be any list of integers, and each item of the result is identical to y in structure.

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

sv decode
.Q.j10 encode binhex
.Q.x10 decode binhex
.Q.j12 encode base64
.Q.x12 decode base64