<div dir="ltr">The tools you need are recursion and pattern matching.<div><br></div><div>Build a set of functions which match on your tuples, uses recursion to compute subtuples into maps, and then builds a map out of the results at this level. Suppose we have</div><div><br></div><div>T = {x, {data, 34, 35}, {data, 21, 22}},</div><div><br></div><div>We can then write a tool</div><div><br></div><div>conv({x, L, R}) -> #{ type => x, left => conv(L), right => conv(R) };</div><div>conv({data, V1, V2}) -> #{ type => data, value1 => V1, value2 => V2 }.</div><div><br></div><div>which can do the conversion by calling itself recursively. These ideas should be applicable to your case as well.</div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 2, 2017 at 11:15 AM Palanikumar Gopalakrishnan <<a href="mailto:palani@vahaitech.com">palani@vahaitech.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><br><br></div>Hi Guys,<br><br></div> I want to convert tuple format into map. This is format of tuple<br><br><br><br><b>{<br>{<br>metadata,<br>2,<br>0,<br><br><br><br> {server_status,false,true,false,false,true,false,false,<br> false,false,false,false,false},<br><br> [<br><br> {<br><br> field_metadata,"def","zurik","erlang","erlang","name",<br> "name",33,135,253,<br> <<0,0>>,<br> 0,<br><br> []<br><br> },<br><br><br> {<br> field_metadata,"def","zurik","erlang","erlang","id",<br> "id",63,11,3,<br> <<0,0>>,<br> 0,<br><br> []<br><br> }<br><br> ],<br> []<br><br> },<br> [<br><br> ["some",457],<br> ["some",457],<br> ["data2sosfasfme",42]<br> ]<br> }<br><br><br><br></b></div>I want to convert this format into map. Please help me to solve this challenge<b> <br></b><div><div><div><div><br><br clear="all"><div><br>-- <br><div class="m_8002666937309266272gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><br></div><div><b>Warm Regards,</b></div></div><div><br></div><div><span style="background-color:rgb(255,255,255)"><span style="font-size:12.8px"><b>Palanikumar Gopalakrishnan </b></span></span><img src="https://ssl.gstatic.com/mail/emoji/6/48px/emoji_u270c.png" alt="✌" style="font-size:small;margin:0px 0.2ex;vertical-align:middle;height:24px;width:24px"><span style="background-color:rgb(255,255,255)"><br></span></div><div><span style="font-size:12.8px;background-color:rgb(255,255,255)"><b>Developer</b></span><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div>
</div></div></div></div></div></div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>