Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang Tuple to String [duplicate]

Tags:

erlang

Is there a way how to convert a tuple to a string ?

Consider I have the following list :

[{atom,5,program},{atom,5,receiving},{nil,5}]

I wish to convert this into the following string:

"{atom,5,program},{atom,5,receiving},{nil,5}"

I have tried using erlang:tuple_to_list on each element in the list, which returns

A = [atom,5,program]

Eventually, I can't concatenate that with "{" ++ A ++ "}"

Any ideas how I can turn that to a string ?

like image 678
cgval Avatar asked Mar 20 '13 21:03

cgval


1 Answers

Term = [{atom,5,program},{atom,5,receiving},{nil,5}].
lists:flatten(io_lib:format("~p", [Term])).
like image 63
Roberto Aloi Avatar answered Nov 24 '22 01:11

Roberto Aloi