key concepts involved (layered in that order):
- matrix is two dimensional list
- indexing at depth: .[;] - see more https://code.kx.com/q4m3/6_Functions/#682-verb-dot
- dot apply : .[;;;] - e.g. https://code.kx.com/q4m3/6_Functions/#687-general-apply-for-dyadic-functions
- projection : f[x;y;z] is same as f[x;;z] y
- iteration : over (/) - e.g. https://code.kx.com/q/ref/adverbs/#over
indexing matrix at depth; as opposed to @ - indexing at first level:
.[10 10#til 100; (2 3; 4 7 9)]
24 27 29
step over list, applying “+” to two arguments previous result and the next element:
(+/)2 3 4
9
amending matrix at given depth indices - step 1
.[10 10#0;;+;1] (1 2 3;1 2 3 4)
0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
amending matrix at given depth indices - step 2
.[10 10#0;;+;1] (2 3;3 4)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
over just one step (first one)
./[10 10#0;;+;1] enlist (1 2 3;1 2 3 4)
0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
list of two steps
((1 2 3;1 2 3 4);(2 3;3 4)) ~ enlist[(1 2 3;1 2 3 4)], enlist (2 3;3 4)
1b
over two steps
./[10 10#0;;+;1] ((1 2 3;1 2 3 4);(2 3;3 4))
0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 2 2 0 0 0 0 0
0 1 1 2 2 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0