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

mats cronqvist <>
Wed Jan 21 14:46:58 CET 2009


Bjorn Gustavsson <> writes:
>
> For consistency with the rest of the lists module (and in particular
> the keysearch/3 function) I think that 'false' is the best value.
>
> (In general, I agree that "half booleans" should be avoided
> in new code.)


  so doing it Right(tm), i.e. returning the value if found or exit(),
  is out of the question?
  seems i've written this function at least a thousand times;

keyfind(Key,N,List) ->
  {value,{Key,Val} = lists:keysearch(Key,N,List),
  Val. 

  mats



More information about the erlang-questions mailing list