You've already posted the simple solutions, but just for variation, here are two less simple ones. These should work for any numeric list.
(|.@{."0~#\) 3 1 4 1 5
3 0 0 0 0
0 1 0 0 0
0 0 4 0 0
0 0 0 1 0
0 0 0 0 5
(-@#{.{:)\ 3 1 4 1 5
3 0 0 0 0
0 1 0 0 0
0 0 4 0 0
0 0 0 1 0
0 0 0 0 5
--
Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
