[erlang-questions] lists:keyfind as an alternative to lists:keysearch

Bjorn Gustavsson bgustavsson@REDACTED
Wed Jan 21 16:28:02 CET 2009

On Wed, Jan 21, 2009 at 2:46 PM, mats cronqvist <masse@REDACTED> wrote:
>  so doing it Right(tm), i.e. returning the value if found or exit(),
>  is out of the question?

Yes. :-)

>  seems i've written this function at least a thousand times;
> keyfind(Key,N,List) ->
>  {value,{Key,Val} = lists:keysearch(Key,N,List),
>  Val.

This version only works for tuples of size 2.

Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list