Reference card

Reserved names

Reserved names denote primitive constants, functions and operators.

Alphabetised

Aabs, acos, aj, aj0, all, and, any, asc, asin, asof, atan, attr, avg, avgs
Bbin, binr
Cceiling, cols, cor, cos, count, cov, cross, csv, cut
Ddelete, deltas, desc, dev, differ, distinct, div, do, dsave
Eeach, ej, ema, enlist, eval, except, exec, exit, exp
Ffby, fills, first, fkeys, flip, floor
Gget, getenv, group, gtime
Hhclose, hcount, hdel, hopen, hsym
Iiasc, idesc, if, ij, in, insert, inter, inv
Kkey, keys
Llast, like, lj, ljf, load, log, lower, lsq, ltime, ltrim
Mmavg, max, maxs, mcount, md5, mdev, med, meta, min, mins, mmax, mmin, mmu, mod, msum
Nneg, next, not, null
Oor, over
Pparse, peach, pj, prd, prds, prev, prior
Rrand, rank, ratios, raze, read0, read1, reciprocal, reval, reverse, rload, rotate, rsave, rtrim
Ssave, scan, scov, sdev, select, set, setenv, show, signum, sin, sqrt, ss, ssr, string, sublist, sum, sums, sv, svar, system
Ttables, tan, til, trim, type
Uuj, ungroup, union, update, upper, upsert
Vvalue, var, view, views, vs
Wwavg, where, while, within, wj, wj1, wsum, ww
Xxasc, xbar, xcol, xcols, xdesc, xexp, xgroup, xkey, xlog, xprev, xrank

By use

Control do, exec, exit, if, while
Filescsv, dsave, get, hclose, hcount, hdel, hopen, hsym, load, read0, read1, rload, rsave, save, set
Iterationeach, over, peach, prior, scan
Listscount, cross, cut, enlist, fills, flip, ratios, raze, reverse, rotate, sv, vs
Logicall, and, any, not, null, or,
Numbersabs, acos, asin, atan, ceiling, cos, deltas, div, exp, floor, inv, log, mmu, mod, neg, prd, prds, rand, reciprocal, signum, sin, sqrt, sum, sums, tan, til, xexp, xlog
OSgetenv, gtime, ltime, setenv, system
Parsing & valuesattr, eval, parse, reval, show, type, value
Selecting from listexcept, first, inter, last, next, prev, sublist, where, xprev
Sorting & searchingasc, bin, binr, desc, differ, distinct, iasc, idesc, in, rank, within, xrank
Statisticsavg, avgs, cor, cov, dev, ema, lsq, mavg, max, maxs, mcount, mdev, med, min, mins, mmax, mmin, msum, scov, sdev, svar, var, wavg, wsum, xbar,
Tables and dictionariesaj, aj0, asof, cols, delete, ej, fby, fkeys, group, ij, insert, key, keys, lj, ljf, meta, pj, select, tables, uj, ungroup, union, update, upsert, view, views, wj, wj1, ww, xasc, xcol, xcols, xdesc, xgroup, xkey
Textlike, lower, ltrim, md5, rtrim, ss, ssr, string, trim, upper

Symbols

()precedence/list/table[]block/arguments{}function
=equal<>not equal>less/greater..
+plus-minus*times
%divided by;separator`symbol
?find/rand/select/exec.index/apply/trap@index/apply/trap
^fill/coalesce$cond/cast/enum..~match
#take_drop/cut,join
!dict/update/delete|max&min
/comment/over/converge\abort/scan/iterate\\quit
/:each right\:each left':each prior/peach
'signal/each both:amend/return::generic null/global amend

Numbers

0:prepare/save/load text
1:binary/save binary
2:dynamic load
1, -1write to stdout
2, -2write to stderr
n, -nsend to handle

Namespaces

Watch out All single-letter namespaces (upper- and lower-case) are reserved for Kx use and should not be used to contain user-written code or data.

.h

for functions in the .h namespace see the .h unreference

.Q

for functions in the .Q namespace see the .Q unreference

.z

.z.aaddress.z.acauth from cookie
.z.bdependencies.z.bmbad message
.z.cphysical core count.z.eTLS connection status
.z.exitaction on exit.z.ffile
.z.hhost.z.iPID
.z.krelease date.z.Kversion
.z.llicense.z.nGMT (timespan)
.z.Nlocal (timespan).z.oOS
.z.pGMT (timestamp).z.Plocal (timestamp)
.z.pcclose.z.pgget
.z.pdpeach handles.z.phHTTP get
.z.piinput.z.pmHTTP OPTIONS method
.z.poopen.z.ppHTTP post
.z.psset.z.pwvalidate user
.z.qquiet mode.z.sself
.z.tstimer.z.uuserid
.z.vsvalue set.z.whandle
.z.wcWebSocket close.z.woWebSocket open
.z.Whandles.z.wsWebSockets
.z.xargv.z.Xraw command line
.z.zGMT time (datetime).z.Zlocal time (datetime)
.z.[tTdD]time/date shortcuts.z.zdZIP defaults

Command-line options and system commands

Summaries of command-line options and system commands

\atables-bblock client write access
\bviews\Bpending views
-c, \cq console size-C, \Cweb console size
\cdcurrent directory\dnamespace
\eerror trap clients-ETLS server mode
\ffunctions -g, \ggarbage collect
-[lL]log updates\lload
-o, \olocal time offset -p, \pport
-P, \Pfloat precision-qquiet
-rreplicate from host/port\rreplication master
\rrename file -suse slaves
\snumber of slaves -S, \Sprng seed
\ttime expression -t, \ttimer
-T, \Ttimeout\tstime and space of expression
-u 1disable system exits\ureload password file
-[uU]usr:pwd file\vvariables
-w, \wworkspace size-W, \Wweek offset
\xexpunge handler-z, \zdate format
\1, \2redirect stdout/stderr\_hide q code

Datatypes

char-size--type-literal--------------q---------sql--------java-------.net---
b    1     1    0b                   boolean              Boolean    boolean
x    1     4    0x0                  byte                 Byte       byte
h    2     5    0h                   short     smallint   Short      int16
i    4     6    0i                   int       int        Integer    int32
j    8     7    0j                   long      bigint     Long       int64
e    4     8    0e                   real      real       Float      single
f    8     9    0.0                  float     float      Double     double
c    1     10   " "                  char                 Character  char
s    .     11   `                    symbol    varchar    String     string
p    8     12   dateDtimespan        timestamp
m    4     13   2000.01m             month
d    4     14   2000.01.01           date      date       Date
z    8     15   dateTtime            datetime  timestamp  Timestamp  DateTime
n    8     16   0D00:00:00.000000000 timespan
u    4     17   00:00                minute
v    4     18   00:00:00             second
t    4     19   00:00:00.000         time      time       Time       TimeSpan
*    4     20.. `s$`                 enum
           98                        table
           99                        dict
           100                       lambda
           101                       unary prim
           102                       binary prim
           103                       adverb
           104                       projection
           105                       composition
           106                       f'
           107                       f/
           108                       f\
           109                       f':
           110                       f/:
           111                       f\:
           112                       dynamic load

The nested types are 77+t (e.g. 78 is boolean. 96 is time.)

Int, float, char and symbol literal nulls are respectively: 0N 0n " " and `.
The rest use type extensions, e.g. 0Nd. No null for boolean or byte.

Infinite dates, times and datetimes are 0Wd 0Wz 0Wt (no math).

date.(year month week mm dd)
dict:`a`b!…
table:([]x:…;y:…) or +`x`y!…
time.(minute second mm ss)
milliseconds: time mod 1000