Don't think you can do that with fill (happy to be proved wrong!).
Assuming you have a column of integers...
(' 0' charsub ":) ,. a
000
012
034
678
020
or alternatively ...
('r<0>0.0' 8!:2 ]) ,. a
000
012
034
678
020
On Tue, Feb 19, 2019 at 1:34 PM 'Skip Cave' via Programming <
[email protected]> wrote:
> NB. I generate a list of integers:
>
> a=.000 012 034 678 020
>
> a
>
> 0 12 34 678 20 NB. Of course, J removes leading zeros.
>
>
> 5 1$ a NB. I invert to a column of integers
>
> 0
>
> 12
>
> 34
>
> 678
>
> 20
>
>
> NB. Now I want to fill the leading zeros back in in the column display, so
> I try the fill (fit) conjunction:
>
> 5 1$!.0 a
>
> 0
>
> 12
>
> 34
>
> 678
>
> 20
>
> NB. Didn't work. What do I have to do to get a verb f, that leading zero
> fills in the columnar display:
>
> NB. Like this:
>
> f a
>
> 000
>
> 012
>
> 034
>
> 678
>
> 030
>
>
> I need a general verb that can take any list of integers, and turn them
> into a column of leading-0-filled integers. Does the result of the verb f
> have to be a literal?
>
> 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