/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
TXT = ["txtvers=1","userid=3A6524D4-E31C-491D-94DD-555883B1600A","name=Jarrod Roberson","version=2"]. A = [ string:tokens(KV,"=") || KV <- TXT]. [["txtvers","1"], ["userid","3A6524D4-E31C-491D-94DD-555883B1600A"], ["name","Jarrod Roberson"], ["version","2"]] D = [{list_to_atom(K),V} || [K|[V|_]] <- A]. [{txtvers,"1"}, {userid,"3A6524D4-E31C-491D-94DD-555883B1600A"}, {name,"Jarrod Roberson"}, {version,"2"}]
URL: http://stackoverflow.com/questions/1822405/convert-nested-lists-into-a-list-of-tuples/1822439