Pascal Jasmin:
> insertitem =: 1 : '(u"_ {. ]) , [ , u"_ }. ]'

> the adverb argument is a verb that tells which item position 
> to insert.  The verb argument is dyadic, but can be a constant 
> verb.  Add @:] to it to just use y as the argument 

>   1 2: insertitem &.|: 3 3 $ 0
> 0 0 1 0
> 0 0 1 0
> 0 0 1 0

To have a noun instead of a verb indicating the position seems
slightly more natural to me. Fortunately your insertitem doesn't
object against u being a noun, because u"_ is again a verb.

   (1+i.3) 2 insertitem 3 3 $ 0 
0 0 0
0 0 0
1 2 3
0 0 0

But even without "_ it works,  because (noun verb verb) 
is also a fork (as I gathered lately).

   insertitem =: 1 : '(u {. ]) , [ , u }. ]'
   (1+i.3) 2 insertitem 3 3 $ 0 
0 0 0
0 0 0
1 2 3
0 0 0

Ben

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

Reply via email to