Skip to content

Instantly share code, notes, and snippets.

@christopheradams
Created April 9, 2014 14:10
Show Gist options
  • Save christopheradams/10274980 to your computer and use it in GitHub Desktop.
Save christopheradams/10274980 to your computer and use it in GitHub Desktop.
Pluck function from newrelic-erlang
pluck(_, _, []) ->
[0];
pluck(Name, N, L) ->
lists:map(fun ([_, []]) -> 0;
([{Struct}, D]) ->
case binary:match(proplists:get_value(name, Struct), Name) of
nomatch ->
0;
_ ->
case proplists:get_value(scope, Struct) =:= <<"">> of
true ->
lists:nth(N, D);
false ->
0
end
end
end, L).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment