pad=: [ ($&'0'@:(- #@:]) , ]) ":@:] 4 g"0 0 a 0001 0002 0003 0004 0005 0010 0020 0030 ...
-------------------------------------------- On Sun, 2/3/19, 'Skip Cave' via Programming <programm...@jsoftware.com> wrote: Subject: [Jprogramming] Adding leading zeros To: "programm...@jsoftware.com" <programm...@jsoftware.com> Date: Sunday, February 3, 2019, 5:36 PM What's the best way to add leading zeros to a set of integers. How to design a verb f, that does the following: a =. 1 2 3 4 5 10 20 30 40 50 100 200 300 400 500 1000 2000 3000 4000 5000 4 f a NB. make each integer a total of 4 digits using leading zeros. 0001 0002 0003 0004 0005 0010 0020 0030 0040 0050 0100 0200 0300 0400 0500 1000 2000 3000 4000 5000 Skip ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm