Reputation: 191
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
Upvotes: 2
Views: 1674
Reputation: 13657
As mentioned by all, #
is the best solution in the singular case. If you wanted to duplicate multiple items into a larger single list, then where
can achieve this nicely
q)`this`that where 4 2
`this`this`this`this`that`that
Upvotes: 7
Reputation: 388
You can do this using #
https://code.kx.com/v2/ref/take/
q)n:4
q)vals:`this
q)n#vals
`this`this`this`this
Upvotes: 2
Reputation: 1692
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
Upvotes: 5