Given a vector, put it on the diagonal of an array:

   (<0 1)&|:inv 2 7 9 20
|index error
   (+/ .*(e.(<0 1 2 )&|:)@i.@(3##)) 2 7 9 20
2 0 0  0
0 7 0  0
0 0 9  0
0 0 0 20
   (, $~ 2##)@(,"0 1*&0)2 7 9 20
2 0 0  0
0 7 0  0
0 0 9  0
0 0 0 20

Are there more concise approaches, that work?

Thanks,

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

Reply via email to