(v,.i) ([EMAIL PROTECTED])`({:@[)`]}"1 _ a
0 1 4 2 0 3
0 1 5 2 0 3
0 1 0 2 6 3
7 1 0 2 0 3
v [`]`(a"_)}"0 i
0 1 4 2 0 3
0 1 5 2 0 3
0 1 0 2 6 3
7 1 0 2 0 3
Both seem bigger than they should be, but I can't do any better.
Henry Rich
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of John Randall
> Sent: Monday, June 11, 2007 9:26 AM
> To: [email protected]
> Subject: [Jprogramming] Amend problem
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm