[erlang-questions] Processing a List into a Dict

Dmitry Vasiliev dima@REDACTED
Mon Nov 30 22:15:31 CET 2009


Jarrod Roberson wrote:
> what I want is something like this
> 
> [{txtvers,"1"}, {userid,"3A6524D4-E31C-491D-94DD-555883B1600A"},
> {name,"Jarrod Roberson"}, {version,"2"}]
> 
> I know there has to be a concise way to do this but I just can't get my head
> around it.

It's simple:

[list_to_tuple(string:tokens(T,"=")) || T <- TXT].

-- 
Dmitry Vasiliev <dima at hlabs.spb.ru>
http://hlabs.spb.ru
http://twitter.com/hdima


More information about the erlang-questions mailing list