[erlang-questions] io:format vs io_lib:format

Christian S chsu79@REDACTED
Sat Aug 25 11:00:13 CEST 2007


2007/8/25, Maximillian Dornseif <md@REDACTED>:
> 43> [io_lib:format("01-~2.10.0B-01~n", [N])  || N <- lists:seq(1, 12)].
> [[48,49,45,["0","1"],45,48,49,"\n"],
>  [48,49,45,["0","2"],45,48,49,"\n"],
...

Do you understand the concept of iolists() ? Check out
erlang:iolist_to_binary/1 and
erlang:iolist_size/1. Flattening is simply not necessary when writing
to files or sending over sockets or directly to ports.

[io:put_chars(io_lib:format("01-~2.10.0B-01~n", [N]))  || N <-
lists:seq(1, 12)].



More information about the erlang-questions mailing list