Search code examples
kdb+

How do I create a list of 1's in KDB?


I'm trying to create a list of 1's in KDB.

I've tried:

{1} each (til 500)

which worked, but is ugly. Is there a more elegant way? (I tried ' as well, but this didn't work).


Solution

  • You can use the 'take' (#) operator for this.

    q)500#1
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1..