I always fall into that trap of using the each crutch when the alternative of just giving ": a rank of 0 is so much more elegant!
Thanks Ric. Cheers, bob > On Feb 18, 2019, at 8: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
