How about using /: as in
ins=: 1 : 0
:
(/:(1+j.m),i.#y){x,y
)
remove the 1+ to work in offset mode
/D
--- Raul Miller <[EMAIL PROTECTED]> wrote:
> I had thought I'd written insert so it would accept list
> arguments for insertion. I did not.
>
> Here's a version which works like I had originally
> intended:
>
> insert=:1 :0
> :
> b=.1#~1 j.m e.~i.#y
> ((-.b)expand x)+b expand y
> )
>
> For example, if I wanted to insert a 4 after both the
> second position in a list (like the original example)
> and after the third position in a list (like the original
> requirement), I could use:
>
> 4 4 (1 2 insert) 2 3 5 6
> 2 3 4 5 4 6
>
> Note that the index 0 would indicate the first position
> (this is just the usual distinction be cardinal and ordinal
> numbers).
>
> That said, if I want this to work with any kind of argument
> (not just numeric), I could use:
>
> ins=:1 :0
> :
> b=.1#~1 j.m e.~i.#y
> x (I.-.b)} b expand y
> )
>
> ' ' 3 5 6 ins 'thisisatest'
> this is a test
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm