Skip to content

Data structures overview

This page provides an overview of the core data structures in q, including their structure and dimensions.

q provides the following data structures:

Name Nr of Elements Definition Example
Atom \(1\) A single, indivisible value of a specific type. 3.14
List \(n \times 1\) An ordered, zero-indexed sequence of values of uniform or mixed type, also called an array. 1 2 3
Dictionary \(n \times 2\) A key-value mapping that associates a list of keys with a list of values. `Alice`Bob`Mike!30 25 43
Table \(n \times m\) A list of conforming dictionaries. ([] name:`Alice`Bob; age:30 25)
Keyed table \(n \times (k + m)\) A dictionary mapping a table of key columns to a table of value columns. ([id:1 2] name:`Alice`Bob; age:30 25)

You can build custom data structures from the basic data structures:

Name Nr of Elements Definition Example
Table dictionary \(\left(\sum_{i=1}^{s} n_i\right) \times m\) A dictionary of tables, in which the key is a unique list and the values are tables (typically sorted by time). (`u#`Alice`Bob)!
(([] time: `s#08:01 16:28; event: `login`logoff); ([] time: `s#08:02 08:29 17:02; event: `login`alarm`logoff))