KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Why sometimes the amend/index doesn’t work?

  • Why sometimes the amend/index doesn’t work?

    Posted by vivo on October 11, 2022 at 12:00 am

    In below code, a1 doesn’t work. Any ideas why?

     

    myObj: (5 7; (`a; `b ; (4 5)));

    a3:.[myObj; 1 2 1; {count x}]; // i.e. ((5 7);(`a;`b;4 1))
    a2:.[myObj; 1 2; {count x}]; // i.e. ((5 7);(`a;`b;2))
    a1:.[myObj; 1; {count x}]; // i.e. it doesn’t work
    a0:.[myObj; (); {count x}]; // i.e. 2

     

    vivo replied 8 months, 2 weeks ago 2 Members · 1 Reply
  • 1 Reply
  • gyorokpeter-kx

    Member
    October 11, 2022 at 12:00 am

    It’s because the dot operator always requires a list as the index. 1 2 1, 1 2 and () are lists, 1 is not. It works if you enlist it.

    a1:.[myObj; enlist 1; {count x}];

Log in to reply.