[erlang-questions] When can you evaluate functions/operations in lists?

Yves S. Garret yoursurrogategod@REDACTED
Mon Jan 6 00:35:05 CET 2014


Recently I tried the following:

82> io:format("~s~n", [os:cmd("ls -l")]).
total 12
-rw-r--r-- 1 dai users 2692 Jan  5 18:28 input_output.beam
-rw-r--r-- 1 dai users 4581 Jan  5 18:28 input_output.erl

83> io:format("~f~n", [20 * 20]).
** exception error: bad argument
     in function  io:format/3
        called as io:format(<0.26.0>,"~f~n",[400])

It struck me as a little odd that while I can execute system functions in a
list (right before printing to console), but not system operations.  Am I
missing something?  When can you do one, but not the other?  Or have I
simply misunderstood something?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140105/437bd481/attachment.htm>

More information about the erlang-questions mailing list