Given the following array:
⎕←a←(3 3⍴⍳9)(5 3⍴10×⍳15)(4 3⍴100×⍳12)
1 2 3 10 20 30 100 200 300
4 5 6 40 50 60 400 500 600
7 8 9 70 80 90 700 800 900
100 110 120 1000 1100 1200
130 140 150
using Pick, on can pick any single value:
2 (2 3)⊃a
60
If I want to pick the 3rd row of the second element of a, I can use:
3⊃⎕split 2⊃a
70 80 90
For a single element, selective assignment is easy. Is there an equivalent for a whole row?
(2 (2 3)⊃a)←6000
a
1 2 3 10 20 30 100 200 300
4 5 6 40 50 6000 400 500 600
7 8 9 70 80 90 700 800 900
100 110 120 1000 1100 1200
130 140 150
A convoluted way would be the follow which requires some knowledge of the array and is probably very inefficient:
((∊(×/¨⍴¨a)⍴¨0 (0 0 0 0 0 0 1 1 1) 0)/∊a)←10000×7 8 9
a
1 2 3 10 20 30 100 200 300
4 5 6 40 50 6000 400 500 600
7 8 9 70000 80000 90000 700 800 900
100 110 120 1000 1100 1200
130 140 150
=============
Second question, if I want to stack these arrays on top of each other, assuming the conform in the 2nd dimension, what is the best way? I can do it this way:
⍉⊃,/⍉¨a
1 2 3
4 5 6
7 8 9
10 20 30
40 50 6000
70000 80000 90000
100 110 120
130 140 150
100 200 300
400 500 600
700 800 900
1000 1100 1200
There are probably simple solutions....