Skip to content

Instantly share code, notes, and snippets.

@Gustav-Simonsson
Created May 8, 2012 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gustav-Simonsson/2635152 to your computer and use it in GitHub Desktop.
Save Gustav-Simonsson/2635152 to your computer and use it in GitHub Desktop.
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