[erlang-questions] Aligned printing with io:format

Anthony Ramine nox@REDACTED
Sun Oct 23 11:19:24 CEST 2011


Le 23 oct. 2011 à 06:54, Kaiduan Xie a écrit :

> How to print the integer in particular width, and right aligned? For
> the width of 3, and for the following input,
> 
> io:format("|~p|~p|~p|~p", [10, 51, 6, 321]).
> 
> The following output is needed,
> 
> |  10|  51|   6| 321|
> 
> What is the format string to produce the desired output? Can't figure
> out from http://www.erlang.org/doc/man/io.html#format-1 :)
> 
> Thanks,
> 
> /Kaiduan

Hi,

io:format("|~4B|~4B|~4B|~4B|~n", [10, 51, 6, 321]).

-- 
Anthony Ramine / @nokusu
Dev:Extend — http://dev-extend.eu/
So as I pray, “Unlimited Erlang Works”




More information about the erlang-questions mailing list