Q Language Indexing - KDB+

What is Q Language Indexing?

A list is ordered from left to proper through the location of its objects. The offset of an object from the start of the list is known as its index. therefore, the first item has an index 0, the second item (if there is one) has an index 1, etc. A list of remember n has index domain from 0 to n–1.

Index Notation

Given a list L, the item at index i is accessed by using L[i]. Retrieving an object by its index is called item indexing. for example,

Indexed Assignment

Items in a list can also be assigned via item indexing. Thus,

Lists from Variables

Joining Lists

The most common operation on two lists is to sign up for them together to shape a larger list. extra precisely, the join operator (,) appends its right operand to the end of the left operand and returns the result. It accepts an atom in both argument.


Data complexity is built by the usage of lists as items of lists.


The variety of ranges of nesting for a list is called its depth. Atoms have a depth of 0 and simple lists have a depth of 1.

Here is a list of depth 3 having two items −

Indexing at Depth

It is possible to index at once into the items of a nested list.

Repeated item Indexing

Retrieving an item through a single index always retrieves an uppermost item from a nested list.

Since the result L[1] is itself a list, we can retrieve its elements using a single index.

We can repeat single indexing once more to retrieve an item from the innermost nested list.

You can read this as,

Get the object at index 1 from L, and from it retrieve the item at index 2, and from it retrieve the item at index 0.

Notation for Indexing at depth

There is an trade notation for repeated indexing into the parts of a nested list. The final retrieval also can be written as,

Assignment via index also works at depth.

Elided Indices

Eliding Indices for a General List

Interpret L[;1;] as,

Retrieve all items within the second position of every list on the top level.

Interpret L[;;2] as,

Retrieve the items in the third role for each list at the second level.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

KDB+ Topics