Fill =: verb define
:
|. x $ |. (x$'0'), ": y
)
5 Fill "0  a

 Transform item of a to string
Add max number of patter in this case '0', x function parameter holds the
max length

Revert the string ex
take the  max length (x)
Revert again the string

Example
Call Fill with 5 max length
And "0 needed to loop for every item in a

Probably exist better solutions

Cheers
Paolo

Am So., 3. Feb. 2019, 09:36 hat 'Skip Cave' via Programming <
[email protected]> geschrieben:

> 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

Reply via email to