Bob & Ric, Thanks! the pad verb does exactly what I specified. However, I have a more complex issue as well - padding a 2 dimensional array.
]b=. 0 12 34 678 20 ,. 3 40 873 9 44 0 3 12 40 34 873 678 9 20 44 I need a pad1 verb that does this: pad1 b 000 003 012 040 034 873 678 009 020 044 What if some columns have 2-digit maximum widths? 4-digit maximum widths? Is it possible to auto-pad to the maximum digit width in a column? Also, Is it possible to generalize this padding to n-dimensional arrays? Skip On Mon, Feb 18, 2019 at 10:14 PM Ric Sherlock <[email protected]> wrote: > Thanks Bob - nice! > I think you could avoid the boxing using: > pad=: _3&({.!.'0')@":"0 > > > On Tue, Feb 19, 2019 at 4:39 PM 'robert therriault' via Programming < > [email protected]> wrote: > > > Hey Ric, > > > > I get a chance to repay the favour of helping me out on StackOverflow > > yesterday. > > This solution relies on some boxing, but it does use fill at its core. > > > > And yes Skip it does end up with a literal result. > > I don't know of a way around that, but I would be happy to be proved > wrong > > as well! > > > > a > > 0 12 34 678 20 > > pad=: > @ (_3&({.!.'0') @ ": each) > > pad a > > 000 > > 012 > > 034 > > 678 > > 020 > > > > Cheers, bob > > > > > On Feb 18, 2019, at 6:00 PM, Ric Sherlock <[email protected]> wrote: > > > > > > ('r<0>0.0' 8!:2 ]) ,. a > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
