Skip to content

Swiss army knife


“Vector from scalar”

  • partition a symbol, string, or bytestream
  • encode a vector from an atom, or a matrix from a vector
x vs y    vs[x;y]


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"
q)", " vs "spring, summer, autumn, winter"
q)"|" vs "red|green||blue"

String or bytestream by linebreak

Where x is the empty symbol `, and y is a string or bytestream, 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"
q)` vs "x"$"abc\ndef\nghi"
q)` vs "abc\r\ndef\r\nghi"
Elides trailing linebreaks

The treatment of linebreaks varies usefully from a left argument of \n.

q)"\n" vs "abc\ndef\nghi\n"
q)` vs "abc\ndef\nghi\n"

Symbol by dot

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

q)` vs `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

sv join


Bit representation

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

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

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

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

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

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

Back to top