KX Community

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

Home Forums kdb+ Why does @ need :: and why does . need () in amend?

  • Why does @ need :: and why does . need () in amend?

    Posted by mannix on January 29, 2023 at 12:00 am

    https://code.kx.com/q/ref/amend/

    Based on the above, why does . need () to get the entire list and @ need ()?

    Surely this would imply:

    q) 1 2 3 4 5 . ()    /this is NOT the case
    1 2 3 4 5

    and

    q) list @ ::    /this is NOT the case
    list

    However

    q)list @ enlist[::]     /this is the case
    list

    Can anyone help me make sense of this?

    mannix replied 9 months, 2 weeks ago 2 Members · 1 Reply
  • 1 Reply
  • gyorokpeter-kx

    Member
    January 30, 2023 at 12:00 am

    The binary form of . is not exactly the same as the 3 or 4 parameter version. The handling of () is special, as it’s equivalent to list[] instead of list . ().

    For list @ :: , this is not the correct syntax for what you want to do as :: is being parsed as a binary operator missing its right argument. If you write it as list @ (::) it works.

    list @ enlist[::] is something else: note that here the index is a list, not a single element, therefore the result will be a list as well, meaning it’s actually enlist[list] – while this looks like the original list in the printout, if you check the type of the result you will notice that they are different.

Log in to reply.