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

https://learninghub.kx.com/forums/topic/what-does-wx0-mean-in-this-linedelwx_wx0y-z-pcdelxeach-t

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

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_: drops from row x the first list that begins with y.