Erlang prints (some) lists as strings

Ulf Wiger etxuwig@REDACTED
Thu Nov 11 09:53:16 CET 1999


On Thu, 11 Nov 1999, Per Hedeland wrote:

per>>That's about what it will take, since Erlang doesn't have a "character" data
per>>type, and the shell has to guess whether any given integer in a list is
per>>meant to be a number or text.
per>
per>Or more precisely, the shell uses the 'p' (or to be pedantic, 'P')
per>control character(*), that asks for the guessing, when printing its
per>output - you don't have to do that in your program:
per>
per>1> L=[111,111,111].      
per>"ooo"
per>2> io:format("~w~n",[L]).
per>[111,111,111]
per>ok
per>3> io:format("~p~n",[L]).
per>"ooo"
per>ok
per>
per>--Per Hedeland
per>per@REDACTED

How about putting the following into c.erl?

w(Term) ->
    io:format("~w~n", [Term]).

which could then be used as:

4> w(L).
[111,111,111]
ok
5> w(v(1)).
[111,111,111]
ok

/Uffe

Ulf Wiger, Chief Designer AXD 301         <ulf.wiger@REDACTED>
Ericsson Telecom AB                          tfn: +46  8 719 81 95
Varuvägen 9, Älvsjö                          mob: +46 70 519 81 95
S-126 25 Stockholm, Sweden                   fax: +46  8 719 43 44




More information about the erlang-questions mailing list