what does this complex format stmt prints?

MEENA SELVAM <>
Fri Aug 26 22:38:53 CEST 2005


In the following io_lib: format what gets printed?

In the simple form we have
io_lib:format("~s ~s\n",[A,B]), where the no of items
to be printed the no of ~s.  e generally means float.
but what does it mean here? can any one briefly
explain?
I believe TX1 ++ TXV1 results in a appended list but
when I try to print the values like:

io_lib:format("~s\n", [TX1]), I get internal error.
same error with io_lib:format("~s\n", [F]) also.

io_lib:format(e("\n~-23s ~4s ~12s ~12s\n", "~54.c~n",
                   TX1 ++ TXV1 ++ TI1 ++ TIV1),
                 e(["Global License
Pools","VPN","Used","Size"], [$-],
                   TX2 ++ TXV2 ++ TI2 ++ TIV2)).


F = fun({{LicType, XId}, Used, Size},{Xfmt,Xacc}) ->
                {"~-23s ~4s ~12w ~12w\n" ++ Xfmt,
                 [lic2str(LicType), a2l(XId), Used,
Size | Xacc]};
           ({LicType, Used, Size},{Xfmt,Xacc}) ->
                {"~-23s ~4s ~12w ~12w\n" ++ Xfmt,
                 [lic2str(LicType), "-", Used, Size |
Xacc]}
        end,




    {TX1,TX2}   =
lists:foldr(F,{"",[]},extract_sort_lic(xnet, Tot)),
    {TXV1,TXV2} =
lists:foldr(F,{"",[]},extract_sort_lic({xnet,vpn},
Tot)),
    {TI1,TI2}   =
lists:foldr(F,{"",[]},extract_sort_lic(ipsec, Tot)),
    {TIV1,TIV2} =
lists:foldr(F,{"",[]},extract_sort_lic({ipsec,vpn},
Tot)),



extract_sort_lic(LicType, Tot) when atom(LicType) ->
    lists:filter(fun(I) when  element(1, I) == LicType
-> true;
                    (_)                               
-> false
                 end, Tot);
extract_sort_lic({LicType, _}, Tot) ->
    Lics =
        lists:filter(fun(I) when element(1, element(1,
I)) == LicType -> true;
                        (_)                           
               -> false
                        end, Tot),
    lists:sort(fun(A,B) ->
                       a2i(element(2,element(1,A))) =<
a2i(element(2,element(1,B)))
               end, Lics).

thanks,
meena


		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 



More information about the erlang-questions mailing list