QStudio
Query kdb+ Servers and Chart Results.
This page is intended as a one page quick lookup of kdb keywords, functions, variables grouped by their area of functionality. Those of you on our kdb+ training course will find a similar function listing printed at the back of your reference booklet.
A printable kdb+ cheat sheet is also available.
Once you're more experienced at kdb, you may want to change to an alpabetically based lookup, like this very useful page at code kx.
sym | description | syntax | eg |
---|---|---|---|
count | Returns the number of items in a list, for atoms 1 is returned | ||
each | Takes a function on its left, and creates a new function that applies to each item of its argument. | count each (1 2;`p`o`i) | |
each | Adverb that takes a function as it's first argument and applies it to each item of it's separate argument. | f each l | reverse each (1 2 3;7 8 9) |
enlist | Take a single argument and return it wrapped it in a list. | enlist X | enlist 1 |
in | Returns a boolean indicating which items of x are in y. Result is same size as x | x in y | 1 4 5 in 10 5 11 1 |
key | Given a dictionary, it returns the keys | r:key D | key (`q`w`e!(1 2;3 4;5 6)) |
not | The logical not function returns a boolean result 0b when the argument is not equal to zero, and 1b otherwise. Applies to all data types except sym. Applies item-wise to lists, dict values and table columns. | r:not X | not -1 0 1 2 |
null | The function null returns 1b if its argument is null.Applies to all data types. Applies item-wise to lists, dict values and table columns. | r:null X | null 0 0n 0w 1 0n |
or | The verb or returns the maximum of its arguments. It applies to all data types except symbol. | r:L or Y | -2 0 3 7 or 0 1 3 4 |
raze | The raze function joins items of its argument, and collapses one level of nesting. To collapse all levels, use over i.e. raze/[x]. An atom argument is returned as a one-element list. | raze (1 2;3 4 5) | |
reverse | Uniform function that reverses the items of its argument. On dictionaries, reverses the keys; and on tables, reverses the columns | reverse 1 2 3 4 | |
rotate | The uniform verb rotate takes an integer left argument and a list or table right argument. This rotates L by N positions to the left for positive N, and to the right for negative N. | r:N rotate L | 2 rotate 2 3 5 7 11 |
show | Monadic function used to pretty-print data to the console. | show 10#enlist til 10 | |
string | The function string converts each atom in its argument to a character string. It applies to all data types. | r:string X | string ([]a:1 2 3;b:`ibm`goog`aapl) |
sublist | The verb sublist returns a sublist of its right argument, as specified by its left argument. The result contains only as many items as are available in the right argument. If X is a single integer, it returns X items from the beginning of Y if positive, or from the end of Y if negative.If X is an integer pair, it returns X 1 items from Y, starting at item X 0. | r:X sublist Y | 3 sublist 2 3 5 7 11 |
system | Monadic function which executes system commands i.e. OS commands. | system"pwd" | |
tables | Monadic function which returns a list of the tables in the specified namespace, this list is sorted. | tables`. | |
til | takes positive integer n and returns list of numbers from 0 to n-1 | til 9 | |
type | This monadic function returns the type of its argument as a short integer. Negatives numbers are for atoms, positive numbers are for lists, and zero is a general K list. | ||
value | When passed a dictionary, This gets the values of a dictionary. | r: value D | value `q`w`e!1 2 3 |
views | Monadic function which returns a list of the currently defined views in the root directory, this list is sorted and has the `s attribute set. |
sym | description | syntax | eg |
---|---|---|---|
gtime | The gtime function returns the UTC datetime/timestamp for a given datetime/timestamp. Recall that the UTC and local datetime/timestamps are available as .z.z/.z.p and .z.Z/.z.P respectively. | ||
ltime | The ltime function returns the local datetime/timestamp for a given UTC datetime/timestamp. Recall that the UTC and local datetime/timestamps are available as .z.z/.z.p and .z.Z/.z.P respectively. | ||
parse | parse is a monadic function that takes a string and parses it as a kdb+ expression, returning the parse tree. To execute a parsed expression, use the eval function. | parse "{x+42} each til 10" | |
view | Monadic function which returns the expression defining the dependency passed as its symbol argument. |
sym | description | syntax | eg |
---|---|---|---|
0: | Prepare. The dyadic prepare text function takes a separator character as its first argument and a table or a list of columns as its second. The result is a list of character strings containing text representations of the rows of the second argument separated by the first. | show csv 0: ([]a:1 2 3;b:`x`y`z) | |
0: | Save. The dyadic save text function takes a file handle as its first argument and a list of character strings as its second. The strings are saved as lines in the file. The result of the prepare text function can be used as the second argument. | ||
0: | Load. The dyadic load text function takes file format description as its first argument and a file handle or a list of character strings as its second. | t:("SS";enlist" ")0:`:/tmp/txt /load 2 columns from space delimited file | |
0: | The format description takes the form of a list of types and either a list of widths for each field if the data to be loaded is fixed width, or the delimiter if delimited, if the delimiter is enlisted the first row of the input data will be used as column names and the data is loaded as a table, otherwise the data is loaded as an list of values for each column. | t:("IFC D";4 8 10 6 4) 0: `:/q/Fixed.txt /reads a text file containing fixed length records | |
0: | note that when loading text you should specify the identifier as an uppercase letter, to load a field as a nested character column or list rather than symbol use '*' as the identifier and to skip a field from the load use ' '. | ||
0: | Optionally, load text can take a three-item list as its second argument, containing the file handle, an offset at which to begin reading, and a length to read. | ("SS";csv)0:(`:/tmp/data.csv;x;x+100000) | |
0: | Also works for key/value pairs. | show "S=;"0:"one=1;two=2;three=3" | |
1 | Write to standard output | 1 "String vector here " | |
1: | The 1: dyadic function is used to read fixed length data from a file or byte sequence. The left argument is a list of types and their widths to read, and the right argument is the file handle or byte sequence. | ("ich";4 1 2)1:0x00000000410000FF00000042FFFF | |
1: | Optionally, it can also take a three-item list as its second argument, containing the file handle, an offset at which to begin reading, and a length to read. | ("ii";4 4)1:(`:/tmp/data;x;x+100000) | |
2 | write to standard error | 2 "String vector here " | |
2: | The 2: function is a dyadic function used to dynamically load C functions into Kdb+. Its left argument is a symbol representing the name of the dynamic library from which to load the function. Its right argument is a list of a symbol which is the function name and an integer which is the number of arguments the function to be loaded takes. | ||
getenv | Returns the value of the given environment variable. | getenv `PATH | |
hcount | Gets the size in bytes of a file as a long integer. | hcount`:c:/q/test.txt | |
hcount | Gets the size in bytes of a file as a long integer. | hcount fh | hcount `:readme.txt |
hdel | Delete a file. | hdel fh | hdel `:readme.txt |
hsym | Converts its symbol argument into a file name, or valid hostname, ipaddress | hsym`10.43.23.197 | |
read0 | The read0 function reads a text file, returning a list of lines.Lines are assumed delimited by either LF or CRLF, and the delimiters are removed. | read0`:test.txt | |
read0 | Optionally, read0 can take a three-item list as its argument, containing the file handle, an offset at which to begin reading, and a length to read. | read0(`:/tmp/data;0;0+100000) | |
read1 | The read1 function reads a file as a list of bytes. | read1`:test.txt | |
read1 | Optionally, read1 can take a three-item list as its argument, containing the file handle, an offset at which to begin reading, and a length to read. | read1(`:/tmp/data;0;0+100000) | |
rload | The rload function loads a splayed table. This can also be done, as officially documented, using the get function. | ||
save | The save function saves data to the filesystem. | t:([]x: 1 2 3; y: 10 20 30);save `t | |
set | Dyadic functional form of assignment often used when saving objects to disk. set is used mainly to write data to disk and in this case the left argument is a file path, i.e. a symbol atom beginning with a : | `:c:/q/testTradeTable set trade | |
setenv | Dyadic function which changes or adds an environment variable. | `name setenv value |
sym | description | syntax | eg |
---|---|---|---|
aj | Asof Join - Joins tables based on nearest time. | aj[c1...cn;t1;t2] | aj[`sym`time; trade; quote] |
ej | Equi Join - Same as ij but allows specifying the column names. | ej[c;t1;t2] | ej[sym; trade; quote] |
ij | Inner Join - Where matches occur between t and kt on primary key columns, update or add that column. Non-matches are not returned in the result. | t ij kt | ([] a:1 2; b:3 4) ij ([a:2 3]; c:`p`o) |
lj | Left Join - for each row in t, return a result row, where matches are performed by finding the first key in kt that matches. Non-matches have any new columns filled with null. | t lj kt | ([] a:1 2; b:3 4) lj ([a:2 3]; c:`p`o) |
pj | Plus Join - Same principle as lj, but existing values are added to where column names match. | t pj kt | |
uj | Union Join - Combine all columns from both tables. Where possible common columns append or new columns created and filled with nulls. | t1 uj t2 | ([] a:1 2; b:3 4) uj ([] a:2 3; c:`p`o) |
wj | Window Join - Join all aggregates within a given time window to a corresponding table. | wj[w;c;t;(q;(f0;c0);(f1;c1))] | wj[w;`sym`time;trade; (quote;(max;`ask);(min;`bid))] |
sym | description | syntax | eg |
---|---|---|---|
abs | Returns the absolute value of a number. i.e. the positive value | abs X | abs -2 -1 0 1 |
acos | Accepts a single argument in radians and returns the arc cosine. | acos[radians] | acos 3.141593 |
all | Function all returns a boolean atom 1b if all values in its argument are non-zero, and otherwise 0b.It applies to all data types except symbol, first converting the type to boolean if necessary. | r:all A | all 1 2 3=1 2 4 |
all | Function all returns a boolean atom 1b if all values in its argument are non-zero, and otherwise 0b.It applies to all data types except symbol, first converting the type to boolean if necessary. | any X | any 1010111001b |
any | Return 1b if there are any non-zero values in it's argument, otherwise return 0b. | any X | any 1010111001b |
asin | Accepts a single argument in radians and returns the arc sine. | sin[radians] | sin 3.141593 |
atan | Accepts a single argument in radians and returns the arc tan. | atan[radians] | atan 3.141593 |
ceiling | When passed floating point values, return the smallest integer greater than or equal to those values. | ceiling X | ceiling 1.2 3.4 5.8 |
cos | Accepts a single argument in radians and returns the cosine. | cos[radians] | cos 3.141593 |
cross | Returns the cross product (i.e. all possible combinations) of its arguments. | R:X cross Y | |
except | Returns all elements of its left argument that are not in its right argument. | x except y | 1 3 2 4 except 1 2 |
exp | This function computes e to the power of x, where e is the base of the natural logarithms. Null is returned if the argument is null. | R:exp 1 | |
flip | transposes its argument, which may be a list of lists, a dictionary or a table. | flip (`a`b`c; 1 2 3) | |
floor | When passed floating point values, return the greatest integer less than or equal to those values. | floor X | floor 1.2 3.4 5.8 |
inter | Returns all elements common to both arguments | x inter y | 1 3 2 4 inter 1 2 6 7 |
inv | inv computes the inverse of a non-singular floating point matrix. | r:inv x | inv (3 3#2 4 8 3 5 6 0 7 1f) |
log | Returns the natural logarithm of it's argument | log X | log 0 1 2.71828 |
max | The max function returns the maximum of its argument. If the argument is an atom, it is returned unchanged. | max a | max 1 |
max | The max function returns the maximum of its argument. If the argument is a list, it returns the maximum of the list. The list may be any datatype except symbol. Nulls are ignored, except that if the argument has only nulls, the result is negative infinity. | max L | max 1 2 3 10 3 2 1 |
maxs | The maxs function returns the maximums of the prefixes of its argument. If the argument is an atom, it is returned unchanged. | maxs a | maxs 1 |
maxs | The maxs function returns the maximums of the prefixes of its argument. If the argument is a list, it returns the maximums of the prefixes of the list. The list may be any datatype except symbol. Nulls are ignored, except that initial nulls are returned as negative infinity. | maxs L | maxs 1 2 3 10 3 2 1 |
mcount | The mcount verb returns the N-item moving count of the non-null items of its numeric right argument. The first N items of the result are the counts so far, and thereafter the result is the moving count. | r:N mcount L | 3 mcount 0N 1 2 3 0N 5 |
mdev | The mdev verb returns the N-item moving deviation of its numeric right argument, with any nulls after the first element replaced by zero. The first N items of the result are the deviations of the terms so far, and thereafter the result is the moving deviation. The result is floating point. | r:N mdev L | 2 mdev 1 2 3 5 7 10 |
med | Computes the median of a numeric list. | r:med L | med 10 34 23 123 5 56 |
min | Returns the minimum value within a list | min X | 3~min 100 10 3 22 |
mmax | The mmax verb returns the N-item moving maximum of its numeric right argument, with nulls after the first replaced by the preceding maximum. The first N items of the result are the maximums of the terms so far, and thereafter the result is the moving maximum. | r:N mmax L | 3 mmax 2 7 1 3 5 2 8 |
mmu | mmu computes the matrix multiplication of floating point matrices. The arguments must be floating point and must conform in the usual way, i.e. the columns of x must equal the rows of y. | r:x mmu y | (2 4#2 4 8 3 5 6 0 7f) mmu (4 3#`float$til 12) |
mod | x mod y returns the remainder of y%x. Applies to numeric types, and gives type error on sym, char and temporal types. | r:L mod N | -3 -2 -1 0 1 2 3 4 mod 3 |
msum | The msum verb returns the N-item moving sum of its numeric right argument, with nulls replaced by zero. The first N items of the result are the sums of the terms so far, and thereafter the result is the moving sum. | r:N msum L | 3 msum 1 2 3 5 7 11 |
neg | The function neg negates its argument, e.g. neg 3 is -3. Applies to all data types except sym and char. Applies item-wise to lists, dict values and table columns. | r:neg X | neg -1 0 1 2 |
prd | Aggregation function, also called multiply over, applies to all numeric data types. It returns a type error with symbol, character and temporal types. prd always returns an atom and in the case of application to an atom returns the argument. | ra:prd L | prd 2 4 5 6 |
rand | If X is an atom 0, it returns a random value of the same type in the range of that type: | r: rand 0 | rand each 3#0h |
rand | If X is a positive number, it returns a random number of the same type in the range [0,X) | r: rand a | rand 100 |
rand | If X is a list, it returns a random element from the list: | r:rand L | rand 1 30 45 32 |
ratios | The uniform function ratios returns the ratio of consecutive pairs. It applies to all numeric data types. | r:ratios L | ratios 1 2 4 6 7 10 |
reciprocal | Returns the reciprocal of its argument. The argument is first cast to float, and the result is float. | r:reciprocal X | reciprocal 0 0w 0n 3 10 |
signum | The function signum returns -1, 0 or 1 if the argument is negative, zero or positive respectively. Applies item-wise to lists, dictionaries and tables, and to all data types except symbol. | r:signum X | signum -2 0 1 3 |
sin | Accepts a single argument in radians and returns the sine. | sin[radians] | sin 3.141593 |
sqrt | Returns the square root of it's argument | sqrt X | sqrt 0 1 4 9 |
sum | Returns the sum total of a list | sum X | 14~sum 2 4 8 |
tan | Accepts a single argument in radians and returns the tan. | tan[radians] | tan 3.141593 |
union | Dyadic function which returns the union of its arguments, i.e. returns the distinct elements of the combined lists respecting the order of the union. | R:X union Y | 1 2 3 union 2 4 6 8 |
var | Aggregation function which applies to a list of numerical types and returns the variance of the list. Again for the usual reason it works on the temporal types. | r:var X | var 10 343 232 55 |
wavg | Dyadic where first arg is weights, second is values, returns the weighted average. | X wavg Y | 7=1 1 2 wavg 5 5 9 |
wsum | The weighted sum aggregation function wsum produces the sum of the items of its right argument weighted by the items of its left argument. The left argument can be a scalar, or a list of equal length to the right argument. When both arguments are integer lists, they are converted to floating point. Any null elements in the arguments are excluded from the calculation. | 2 3 4 wsum 1 2 4 | |
xexp | This is the dyadic power function. | r:xexp[X;Y] | 2 xexp 3 |
sym | description | syntax | eg |
---|---|---|---|
bin | bin gives the index of the last element in x which is <=y. The result is -1 for y less than the first element of x.It uses a binary search algorithm, which is generally more efficient on large data than the linear search algorithm used by ?.The items of the left argument should be sorted non-descending although q does not enforce it. The right argument can be either an atom or simple list of the same type as the left argument. | r:x bin y | 0 2 4 6 8 10 bin 5 |
cols | Return a symbol list of column names for a given table, or a list of keys for a dictionary. | cols[table] | cols trade |
eval | The eval function is the dual to parse and can be used to evaluate a parse tree as returned by that function (as well as manually constructed parse trees). | eval parse "2+3" | |
fills | Uniform function that is used to forward fill a list containing nulls. | r:fills A | fills (0N 2 3 0N 0N 7 0N) |
group | Groups the distinct elements of its argument, and returns a dictionary whose keys are the distinct elements, and whose values are the indices where the distinct elements occur. The order of the keys is the order in which they are encountered in the argument. | D:group L | group "mississippi" |
iasc | Uniform function that returns the indices needed to sort the list argument. | r:iasc L | iasc (2 1 3 4 2 1 2) |
idesc | Uniform function that returns the indices needed to sort the list argument. | r:idesc L | idesc (2 1 3 4 2 1 2) |
key | Given a keyed table, Returns the key columns of a keyed table | r:key KT | key ([s:`q`w`e]g:1 2 3;h:4 5 6) |
key | Given a directory handle, returns a list of objects in the directory | r:key DIR | key`:c:/q |
key | Given a file descriptor, returns the descriptor if the file exists, otherwise returns an empty list | r:key filedesc | key`:c:/q/sp.q |
key | Given a foreign key column, returns the name of the foreign key table | ||
key | Given a simple list, returns the name of the type as a symbol | key L | key each ("abc";101b;1 2 3h;1 2 3;1 2 3j;1 2 3f) |
key | Given an enumerated list, it returns the name of the enumerating list | key eL | |
key | Given a positive integer, it acts like til | key n | key 10 |
keys | Monadic function which takes a table as argument and returns a symbol list of the primary key columns of its argument and in the case of no keys it returns an empty symbol list. Can pass the table by reference or by value | keys T | keys ([s:`q`w`e]g:1 2 3;h:4 5 6) |
last | Returns the item at the end of the list or table | last X | 7~last 2 3 4 7 |
over | The over adverb takes a function of two arguments on its left, and creates a new atomic function that applies to successive items of its list argument. The result is the result of the last application of the function. | r:f over L | {x+2*y} over 2 3 5 7 |
peach | The parallel each adverb is used for parallel execution of a function over data. In order to execute in parallel, q must be started with multiple slaves (-s). | {sum exp x?1.0}peach 2#1000000 | |
rank | The uniform function rank takes a list argument, and returns an integer list of the same length. Each value is the position where the corresponding list element would occur in the sorted list. This is the same as calling iasc twice on the list. | r:rank L | rank 2 7 3 2 5 |
scan | The scan adverb takes a function of two arguments on its left, and creates a new uniform function that applies to successive items of its list argument. The result is a list of the same length. | r:f scan L | {x+2*y} scan 2 3 5 7 |
sv | scalar from vector- dyadic function that performs different functions on different data types. | ||
sv | In the special case where the left argument is a `, it returns the concatenated right arg with each element terminated by a newline ( on unix, on windows). | ` sv ("asdf";"hjkl") | |
sv | When applied to a symbol list where the first element is a file handle and the left argument is a ` sv returns a file handle where the elements of the list are separated by slashes-this is very useful when building write paths | wp:`:c:/q/data; (`)sv wp,`2005.02.02,`trade | |
sv | In the case of using sv on a symbol list where the left argument is a ` it returns the elements separated by . this is useful for generating files with the required extension | fp:`c:/q/sym; hsym` sv fp,`txt | |
sv | Evaluates base value | rl: N sv L | 10 sv 23 45 677 |
sv | Converts bytes to ints base 256 | 0x0 sv "x"$12 3 4 5 | |
ungroup | The ungroup function monadic function ungroups a table. | ||
value | This is the same verb as get but is typically used for different things. | ||
value | When passed an object by reference it returns the value of that object | D:`q`w`e!1 2 3 ; value `D | |
value | When passed object has an enumerated type, it returns the corresponding symbol list: | ||
value | When passed object is a lambda, it returns a list:(bytecode;params(8);locals(24);globals(32),Constants(96) | ||
value | When passed object is a projection, it returns a list where projected function is followed by parameters: | value +[2] | |
value | When passed object is a composition, it returns a list of composed functions: | value rank | |
value | When passed object is a primitive it returns an internal code: | value each (::;+;-;*;%) | |
value | When passed object is an adverb modified verb, it strips the adverb: | value (+/) | |
value | When passed a string with valid q code, it evaluates it: | value"b:`a`b`c" | |
value | When passed a list, applies the first element to the rest: | value(+;1;2) | |
value | If the first element of the list is a symbol, it is evaluated first: | value(`.q.neg;2) | |
vs | The dyadic vs vector from scalar function has several uses. | ||
vs | With 0b on the left hand side, it returns the bit representation of the integer on the right hand side. | 0b vs 1024h | |
vs | With 0x0 on the left hand side, it returns the byte representation of the number on the right hand side. | 0x0 vs 1024 | |
vs | With ` on the left hand side splits symbols on the . ; breaks file handles into directory and file parts; and domain names into components. | ` vs`:/foo/bar/baz.txt |
sym | description | syntax | eg |
---|---|---|---|
delete | two Formats. Either delete rows or delete columns from table. | delete col from t. delete row from t where filter. | delete from t where price<10 |
differ | The uniform function differ returns a boolean list indicating whether consecutive pairs differ. It applies to all data types. (The first item of the result is always 1b) | r:differ A | |
fby | This verb is typically used with select, and obviates the need for many common correlated subqueries. It aggregates data in a similar way to by and computes a function on the result. | (aggr;data) fby group | |
fkeys | The function fkeys takes a table as an argument and returns a dictionary that maps foreign key columns to their tables. | ||
insert | Insert appends records to a table. | `table insert records | `x insert (`s`t;40 50) |
meta | The meta function returns the meta data of its table argument, passed by value or reference. | K:meta T | meta ([s:`q`w`e]g:1 2 3;h:4 5 6) |
select | Select rows from a table. | select columns by groups from table where filters | select max price by date,sym from trade where sym in `AA`C |
update | Modify the table to update existing values or to create a new column. | update col by c2 from t where filter | update price:price+10 from t where sym=`A |
upsert | Functional form of inserting into a table using the , primitive. It is called upsert because when applied to keyed tables it performs an insert if the key value is not there and otherwise performs an update. | r: T upsert newEntries | ([s:`q`w`e]r:1 2 3;u:5 6 7) upsert (`q;100;500) |
where | Where the argument is a boolean list, this returns the indices of the 1's | where 21 2 5 11 33 9>15 | |
within | The right argument of this primitive function is always a two-item list. The result is a boolean list with the same number of items as the left argument. The result indicates whether or not each item of the left argument is within the bounds defined by the right argument. | 1 3 10 6 4 within 2 6 | |
within | The within function also applies to chars and syms because both are ordered | "acyxmpu" within "br" | |
within | The within function will also work with a pair of n-ary lists as the right argument and an atom, a n-ary list or n-by-* ragged matrix as the left argument. The results in this case take the shape of the left argument. | 5 within (1 2 6;3 5 7) | |
wj | Window join is a generalization of asof join, and is available from kdb+ 2.6. asof join takes a snapshot of the current state, while window join aggregates all values of specified columns within intervals. | ||
xasc | Dyadic function-sorts a table in ascending order of a particular column, sorting is order preserving among equals. Takes a symbol list or atom and a table as arguments and returns the original table sorted by the columns as specified in the first argument. | R:C xasc T | t:`sym xasc trade |
xasc | It can be used to sort data on disk directly. xasc can be used to sort a splayed table on disk one column at a time without loading the entire table into memory. | see notes | |
xbar | Interval bars are prominent in aggregation queries. For example, to roll-up prices and sizes in 10 minute bars: | select last price, sum size by 10 xbar time.minute from trade | |
xcol | Dyadic function - rename columns in a table. Takes a symbol list of column names and a table as arguments, and returns the table with the new column names. The number of column names must be less than or equal to the number of columns in the table. The table must be passed by value. | R:C xcol T | `A`S`D`F xcol trade |
xcols | Dyadic function - reorder columns in a table. Takes a symbol list of column names and a table as arguments and returns the table with the named columns moved to the front. The column names given must belong to the table. The table must have no primary keys and is passed by value. | R:C xcols T | xcols[reverse cols trade;trade] |
xgroup | The xgroup function dyadic function groups its right argument by the left argument (which is a foreign key). | ||
xkey | Dyadic function-sets a primary in a table. Takes a symbol list or atom and a table as arguments and returns the original table with a primary key corresponding to the column(s) specified in the first argument. | R:C xkey T | `r xkey ([s:`q`w`e]r:1 2 3;u:5 6 7) |
xprev | Uniform dyadic function, returns the n previous element to each item in its argument list. | r:N xprev A | 2 xprev 2 3 4 5 6 7 8 |
xrank | Uniform dyadic function which allocates values to buckets based on value. This is commonly used to place items in N equal buckets. |
sym | description | syntax | eg |
---|---|---|---|
like | Perform simple pattern matching of strings. | like[text; pattern] | like[("kim";"kyle";"Jim"); "k*"] |
lower | Monadic that converts strings and symbols to lower case | lower[text] | `small~lower `SMALL |
ltrim | Monadic that removes leading whitespace from strings. | ltrim[text] | "abc"~ltrim " abc" |
rtrim | Monadic that removes trailing whitespace from strings. | rtrim[text] | "abc"~rtrim "abc " |
ss | The function ss finds positions of a substring within a string. It also supports some pattern matching capabilities of the function like: | r:HayStack ss needle | "toronto ontario" ss "ont" |
ssr | The function ssr does search and replace on a string. | r:ssr[haystack; needle; replacement] | ssr["toronto ontario"; "ont"; "XX"] |
sv | When applied to a vector of strings it returns the elements of its right argument-the list of strings-separated by the left argument. | "|" sv ("asdf";"hjkl") | |
trim | Monadic that removes leading and trailing whitespace from strings. | trim[text] | "abc"~trim " abc " |
upper | Monadic that converts strings and symbols to upper case | lower[text] | `BIG~upper `big |
vs | With a character or a string on the left hand side, it tokenizes a string on the right hand side using the left hand side as the specified delimiter. It returns a vector of substrings. | ","vs"one,two,three" |
Query kdb+ Servers and Chart Results.