Return to Snippet

Revision: 20900
at November 30, 2009 16:16 by fuzzylollipop


Initial Code
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"}]

Initial URL
http://stackoverflow.com/questions/1822405/convert-nested-lists-into-a-list-of-tuples/1822439

Initial Description

                                

Initial Title
Convert nested Lists into a List of Tuples - Erlang

Initial Tags

                                

Initial Language
Other