ListOfFloats = [ Y || {Y,_} <- [string:to_float(X) || X <- ListOfStrings]].
Refactorings
No refactoring yet !
Ferd
January 7, 2010, January 07, 2010 20:34, permalink
The following might save you a few traversals at the cost of cleaner code.
[ F || X <- ListOfStrings, {F,_} <- [string:to_float(X)]]
Mazen Harake
March 29, 2011, March 29, 2011 19:48, permalink
This is more correct imho.
ListOfFloats = [ element(1,string:to_float(X)) || X <- ListOfStrings ].
Is there a nicer way to 'convert' a list of strings to a list of floats?