KX Community

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

Home Forums KX Academy What does w[x;;0] mean in this line:del:{w[x]_:w[x;;0]?y};.z.pc:{del[;x]each t};

  • What does w[x;;0] mean in this line:del:{w[x]_:w[x;;0]?y};.z.pc:{del[;x]each t};

    Posted by mannix on March 15, 2022 at 12:00 am

    From the standard tick setup from KX systems: what does w[x;;0] mean in this line: del:{w[x]_:w[x;;0]?y};.z.pc:{del[;x]each t};

    mannix replied 6 months, 3 weeks ago 2 Members · 1 Reply
  • 1 Reply
  • Laura

    Administrator
    March 15, 2022 at 12:00 am

    The line consists of two definitions: of del and of .z.pc.

    The former is a lambda that amends the value of an existing value w. We can see from w[x;;0] that w is a list with at least rank 3, i.e. three levels of indexing. Say w is a list in which the items are lists of lists. Then w[x;;0] refers to the first items of the lists in row x.

     

    q)show w:3 cut” “vs”The quick brown fox jumps over the lazy dog.”

    “The” “quick” “brown” “fox” “jumps” “over” “the” “lazy” “dog.”

    q)w[1;;0]

    “fjo”

    q)w[1]_:w[1;;0]?”j”

    q)w (“The”;”quick”;”brown”) (“fox”;”over”) (“the”;”lazy”;”dog.”)

     

    Then w[x;;0]?y finds the first occurrence of y among them. Where is an operator the syntax x:y is equivalent to x:xy, so the w[x]_: drops from row x the first list that begins with y.

Log in to reply.