Here's an alternative that doesn't require numeric lists:

   insertA=: 13 : '(x{.>1{y),(>0{y),x}.>1{y'
   3 insertA 4;2 3 5 6
2 3 5 4 6
   3 insertA 4 4.1 4.2 4.3;2 3 5 6
2 3 5 4 4.1 4.2 4.3 6
   3 insertA 'XXX';'ABCDEF'
ABCXXXDEF
   3 insertA ('BBB';'BB');<'AAA';'AA';'A';'B';'CCC'
+---+--+-+---+--+-+---+
|AAA|AA|A|BBB|BB|B|CCC|
+---+--+-+---+--+-+---+


On 8/23/07, Raul Miller <[EMAIL PROTECTED]> wrote:
>
> On 8/23/07, Fuchs Ira <[EMAIL PROTECTED]> wrote:
> > Is there a primitive verb which will insert a value in a list?
>
> No.  And, unless you are prepared to combine arguments
> (perhaps inserted values and locations), there cannot be:
> the operation you describe requires three arguments.
>
> For example:
> insert=:1 :0
> :
>   b=.1#~1 j.m=i.#y
>   ((-.b)expand x)+b expand y
> )
>
>
>    4 (2 insert) 2 3 5 6
> 2 3 5 4 6
>
> > If not, what is the simplest definition for doing this?
>
> That depends on what exactly you mean by "this".  More specifically,
> what are the full domains of each of your intended potential arguments?
>
> Thanks,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to