Here is a verb which does the same thing as Dan's
adverb if the left hand argument is the positions and the
righthand argument is the inserts followed by the original
list.

   insv =: ]{~  >:@[/:@,[EMAIL PROTECTED]&#
   1 1 3  insv 0 2 4 , 2 3 5 6
2 3 0 2 5 6 4

On Thu, 23 Aug 2007, Brian Schott wrote:

+ Dan,
+
+       I get better results by leaving out j. from your
+ solution if m can be a vector of the same length as x.
+
+    ins=: 1 : 0
+ :
+ (/:(1+m),i.#y){x,y
+ )
+    0 4(1 3  ins) 2 3 5 6
+ 2 3 0 5 6 4
+    0 4(3 1   ins) 2 3 5 6
+ 2 3 4 5 6 0
+
+

(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to