how to get [3,5] from [ ["3"], ["5"] ] - it works! i used string:to_integer

MEENA SELVAM meena_selvam@REDACTED
Sun Aug 7 08:39:10 CEST 2005


FinalList = fun(X) -> {I} = string:to_integer(X),
                      I
             end.
 
 lists:map(FinalList, [["3"],["5"]]).

--- MEENA SELVAM <meena_selvam@REDACTED> wrote:

> Will this code work?
> 
> FinalList = fun(X) -> io_lib:format("~7s',X)
>             end.
> 
> lists:map(FinalList, [["3"],["5"]]).
> 
> my requirement is for a arbitrary number of elements
> rather than 3 and 5.
> 
> PS: Right now, I do not have access to erlang
> compiler,  so I am yet to try this out.
> 
> my doubt is, io_lib:format writes on terminal, but
> does it return the character that is printed or some
> other return values.
> 
> is there anything similar to sprintf in c, in
> formatting and moving the output of to a list?
> 
> meena
> 
> --- MEENA SELVAM <meena_selvam@REDACTED> wrote:
> 
> > Hi,
> > I need to extract the first element of every
> tuple,
> > in
> > a tuplelist in the format[a,b]
> > 
> > what I have is:
> > 
> > FirElem = fun(X)->
> >             {C,_} = X,
> >             C
> >           end.
> > 
> >
>
lists:map(FirElem,[{["3"],["red"]},{["5"],["yellow"]}]).
> > 
> > which gives [["3"],["5"]]
> > 
> > But I require to make a list [3,5] for which I do
> > not
> > find any BIF or functions( to convert
> [["3"],["5"]].
> > Any suggestions?
> > 
> > meena
> > 
> > 
> > 		
> >
> ____________________________________________________
> > Start your day with Yahoo! - make it your home
> page 
> > http://www.yahoo.com/r/hs 
> >  
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 



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



More information about the erlang-questions mailing list