Created
July 7, 2012 15:43
-
-
Save l4u/3066929 to your computer and use it in GitHub Desktop.
erlang list comprehension finding value given a key
This file contains hidden or 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
[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