b_jonas wrote (in IRC chat):
Ok, let's just summarize them here by copying the five solutions I've gotten.
NB. inputs were
b;a
+-------+-----------------------+
|0 4 5 7|3 1 4 1 5 9 2 6 5 3 5 8|
+-------+-----------------------+
NB. the first solution is
(10*b{a) b} a NB. explicit
30 1 4 1 50 90 2 60 5 3 5 8
b (10*[{])`[`]} a NB. or tacit amend
30 1 4 1 50 90 2 60 5 3 5 8
NB. the other four need this mask
]bm =: b e.~ i.#a
1 0 0 0 1 1 0 1 0 0 0 0
NB. so the second was
bm {"0 1 (,"0(10&*)"0) a NB. index
30 1 4 1 50 90 2 60 5 3 5 8
NB. third was
bm} (,: 10&*"0) a NB. item amend
30 1 4 1 50 90 2 60 5 3 5 8
NB. fourth was
bm (10&*@:])^:["0 a NB. power
30 1 4 1 50 90 2 60 5 3 5 8
NB. and fifth was
bm ]`(10&*@:])@.["0 a NB. agenda
30 1 4 1 50 90 2 60 5 3 5 8
Now which one is the best you decide, depending on the verb (10&a), how large your input is (#a), and how many elements of them you want to replace (#b). (Some of the examples might need to be changed in minor ways if (a) has a higher rank.)
Note that item amend can be quite fast in some cases. Namely, notice that your verb (10&*) here is applied to the whole vector at once, you don't need to rank it if it handles a rank built in, so it uses fast vector ops and item amend should be optimized.See also: http://www.jsoftware.com/pipermail/programming/2008-August/011614.html
