Skip to content

Instantly share code, notes, and snippets.

@l4u
Created July 7, 2012 15:43
Show Gist options
  • Save l4u/3066929 to your computer and use it in GitHub Desktop.
Save l4u/3066929 to your computer and use it in GitHub Desktop.
erlang list comprehension finding value given a key
[Y] = [X || {<<"type">>, X} <- Terms]
Y = proplists:get_value(<<"type">>, Terms)
Y = lists:keysearch(<<"type">>, 1, Terms)
%% From #erlounge
%% jlouis: l4u: lists:keysearch is usually very fast because it is implemented as a BIF, but proplists is more general and the thing Licenser suggested is reasonably fast as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment