Send Feedback
Skip to content

Data Structures Overview

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

In q, the following data structures exist:

Name Nr of Elements Definition Example
Atom \(1 \times 1\) A single, indivisible value of a specific type. 3.14
List/Array \(n \times 1\) An ordered, zero-indexed sequence of values, which can be uniform or mixed type. 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 collection of named, equal-length columns stored as a flipped dictionary. ([] 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 Dimension Definition Example
Table Dictionary \(\sum^s_{i=1}= n_{i} \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))