Search code examples
kdb

How to create a list of length x with identical elements?


I would like to create a list in q/kdb of variable length x which contains the same element e repeated. For example:

x:4;
e:`this;
expected_result:`this`this`this`this

Solution

  • Take is what you're looking for: https://code.kx.com/v2/ref/take/

    q)x:4
    q)e:`this
    q)x#e
    `this`this`this`this