For some reason I have a blind spot with amend.

I have the following problem:

a is a list of integer values

i is a list of indices into a, possibly with repeats

v is a list of values of the same length as i


For each value,index pair, I want to insert the value at the index in
a copy of a, and assemble the results.  If it helps, index { a is
zero.  I also want this to be as fast as possible (it is an inner loop
in my solution to the Meteor problem).

For example, if

a=:0 1 0 2 0 3
i=:2 2 4 0
v=:4 5 6 7

I want the result to be

0 1 4 2 0 3
0 1 5 2 0 3
0 1 0 2 6 3
7 1 0 2 0 3

Any suggestions would be appreciated.

Best wishes,

John


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to