>, <<"b">>, <<"c">>] to ["a", "b", "c"] ? +6 erlang sura2k Dec 27 '11 at 9:46 source...">

Binary List to String List - Erlang

How to convert [<<"a">>, <<"b">>, <<"c">>] to ["a", "b", "c"] ?

+6
source share
3 answers

[binary_to_list(X) || X <- [<<"a">>, <<"b">>, <<"c">>]]. or in more detail

  BinList = [<< "a" >>, << "b" >>, << "c" >>],
 NormalList = [binary_to_list (X) ||  X <- BinList],
 NormalList.
+8
source

Or using the lists: map / 2:

 lists:map(fun erlang:binary_to_list/1, [<<"a">>, <<"b">>, <<"c">>]). 
+5
source

you can do it like this:

 A=[<<"a">>, <<"b">>, <<"c">>] B=[binary_to_list(Item) || Item <- A] 
+2
source

Source: https://habr.com/ru/post/904523/


All Articles