Created
May 8, 2012 13:47
-
-
Save Gustav-Simonsson/2635152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to_proplist_meta(Meta,Rs) -> | |
lists:map( | |
fun(Res) -> | |
Elems = fun(Ele, Cnt) -> | |
V = if element(Cnt,Res) == null -> undefined; | |
true -> element(Cnt,Res) end, | |
{{Ele,V},Cnt+1} | |
end, | |
{Base,BaseCnt} = lists:mapfoldl(Elems, 1, hd(Meta)), | |
{Other,_} = lists:mapfoldl( | |
fun({Name,Tags},Cnt) -> | |
{Vals,NewCnt} = lists:mapfoldl(Elems,Cnt, | |
Tags), | |
{{Name,Vals},NewCnt} | |
end,BaseCnt,tl(Meta)), | |
Base++Other | |
end,Rs). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment