Skip to content
This repository

Wiki editors are welcome. Any logged in GitHub user can edit. You do not need anyone’s permission to edit the wiki.

You can add anything you want to the wiki. Don’t worry about making it publication quality, just add it. You can even add informal notes you’ve taken. In fact, we’d appreciate it. If you’re not sure where to put something create a new page and link to it from the main page.

If you want to contribute but need help choosing something to work on there is always the issue list which is full of things that need improvement. Anyone may work on issues from the list.

Questions about Kona

If you do not find the information you are looking for about Kona on the web, two great places to ask are on either our Kona User or Kona Project Developer list (see below). These are open discussion lists without topic restrictions.

Please use a discussion list whenever possible instead of cold emailing an individual maintainer. All the maintainers will see your question on the discussion lists. The discussion list may give you more and faster information by giving more people a chance to answer. Answering questions on the mailing list lets us keep an archive to refer to people with similar questions in the future.

Discussion Lists

There are two discussion lists: kona-dev and kona-user. The dev/user divide is designed to split discussion between development on K and development with K.

Until the traffic warrants otherwise it is fine to talk about user issues on the dev list.

K Development List

K Users List

Pages

Tutorial Intro Screencast
K 99: Ninety Nine K Problems
Tutorial
Verbs-Classification
Project Euler Code Golf: Project Euler Code Golf
Project Coding Guidelines: Coding Guidelines
List of idioms: Idioms
Dictionaries: Dictionaries
Strings: Strings
Data and Execution: Data and Execution
Primitive Operations Primitive Operations
C Reference C Reference
Examples Examples
Memory Management Memory Management
Amend Amend
Random Lines of K gist
Verbs, Functions, Projections Functions
Replicating SQL functionality Replicating SQL functionality
shared library shared library
more Memory management newK, unpool, repool, kap
csv loading csv loading and dictionary

Links

hakank’s K/Kona Page
Whitney on K
No Stinking Loops
Remarks on Style
K by example
K as a Prototyping Language
A Shallow Introduction to the K Programming Language
K on Rosetta Code
Kx Corporate Website
Kx K Examples
Gordon Baker’s Q site
Milan Ondrus’s KDB+ site
Introduction to K
kdbfaq blog
K 2.0 Reference Card [PDF]
FinnAPL Idioms
kdb faq on thalesians
Q for Mortals Book on Amazon
K User Manual
K Reference Manual
A+
J

Screencasts

Introduction to K
MapReduce in K

Off-site user groups

LinkedIn Group: [Kx] Technology Network [Jobs]
LinkedIn Group: KDB+/Q User Group
LinkedIn Group: Kx/KDB+ Networking Forum [Jobs]
Kx’s KDB+ Personal Developers Google Group

Helpful Commands

Command What It Does
\ Shows ‘Help’
.` Shows the full K-Tree

Verbs

Verb Monadic Dyadic Triadic Tetradic
+ flip plus
negate minus
* first times
% reciprocal divide
| reverse max_or
& where min_and
^ shape power
! enumerate rotate_mod
< grade up less_than
> grade down greater_than
= group equals
~ not/attribute match
@ atom at index amend/trap amend
? range function inverse/find/draw/deal/sample invert-guess
_ floor (tolerant) drop_cut
, enlist join
# count take_reshape
$ format dollar
. dot/monadic/make/unmake dot index amend/trap amend
: colon/monadic colon/dyadic

Adverbs

Adverb Definition
/ over
\ scan
each
/: each right
\: each left
’: eachpair

Input/Output Verbs

Verb Monadic Dyadic
0: read text file. write text file
read from stdin until EOF (empty symbol). write to stdout if first param is an empty symbol ( `0:stuff_to_print )
1: read binary file (mmapped) write binary file
2: read binary file (copied to memory) dll function call
3: open handle/close handle asynchronous send
4: type of data synchronous send
5: printed representation append to binary file
6: read raw byte string write raw byte string

Control Flow

Name Use Example
: :[\(cond_1;ret_1;cond_2;ret_2;\ldots;cond_n;ret_n;ret_{else}\)] not_x: :[0=x;1;0]
if if[\(cond;exp_1;exp_2;\ldots;exp_n\) ] if[n!2; n:1+3*n; `0:"n was odd\n"]
while while[\(cond; exp_1; exp_2;\ldots;exp_n \) ] while[~a!2; a %: 2; `0:"dividing\n"]
do do[\(n;exp_1;exp_2;\ldots;exp_m\)] do[4; `0:"******\n"]

Commands

Command Definition
\ show help
\p [n] [set] print precision
\r [seed] [set] random seed
\+ print operator reference
\l [script] load k script
\s [script] step k script
\t [code] time execution (in ms)

Reserved Words

All reserved words start with a leading underscore(_)

Constants

Name Definition
_T [current UTC Julian day count]+[fraction complete] (K epoch is 2035-01-01T00:00:00)
_a program argument vector (argv)
_d K-Tree path / current working dictionary
_f anonymous reference to current function
_h host name
_i
_k
_m
_n nil
_p
_s
_t current UTC time (int) (K epoch is 2035-01-01T00:00:00)
_u
_v
_w

Monadic Verbs

Name Definition
_acos inverse cosine
_asin inverse sine
_atan inverse tangent
_ceil ceiling (intolerant)
_ceiling ceiling (tolerant)
_cos cosine
_cosh hyperbolic cosine
_exp exponential
_floor largest previous integer (intolerant)
_log natural logarithm
_sin sine
_sinh hyperbolic sine
_sqr square
_sqrt square root
_tan tangent
_tanh hyperbolic tangent
_abs absolute value
_bd convert to binary representation
_ci char-of-int (octal if unprintable char)
_db construct from binary representation
_dj date from Julian day count
_exit exit with status x
_getenv get an environment variable
_gtime in UTC, ints: YYYMMDD,HHMMSS (_gtime _t)
_host host name IP address (int)
_ic int-of-char
_inv inverse of a matrix
_jd Julian day count from date _jd 20110315
_lt convert output of _t to local time
_ltime localized version of _gtime
_size size of file (bytes)

Dyadic Verbs

Name Definition
_bin index of element using binary search
_binl search for several elements
_di delete element at index
_dot dot product
_draw draw x random numbers from 0 to y-1 (compare: ?)
_dv delete value
_dvl delete several values
_in true if x is in y
_lin _in for several values
_lsq matrix division
_mul matrix multiplication
_setenv set environment variable
_sm string match
_ss positions of substring y in string x
_sv scalar from vector with base change
_vs vector from scalar with base change

Triadic Verbs

Name Definition
_ssr string search & replace

Command-line Arguments

Name Definition
-h (int) open an HTTP port
-i (int) open an IPC port
-e (string) execute a string
-x (string) execute a string and print
[file] execute a script (as in ./k script.k, extension optional)
Something went wrong with that request. Please try again.