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}; › Re: What does w[x;;0] mean in this line:del:{w[x]_: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 fromw[x;;0]
thatw
is a list with at least rank 3, i.e. three levels of indexing. Sayw
is a list in which the items are lists of lists. Thenw[x;;0]
refers to the first items of the lists in rowx
.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 ofy
among them. Where is an operator the syntaxx:y
is equivalent tox:xy
, so thew[x]_:
drops from rowx
the first list that begins withy
.