Differences between revisions 1 and 2
 ⇤ ← Revision 1 as of 2008-08-11 15:46:37 → Size: 1435 Editor: TracyHarms Comment: Page creation; transcription from IRC ← Revision 2 as of 2008-12-08 10:45:51 → ⇥ Size: 1435 Editor: anonymous Comment: converted to 1.6 markup No differences found!

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.```

TracyHarms/notebook/selectivealteration (last edited 2008-12-08 10:45:51 by anonymous)