[erlang-questions] performing lists:keysearch on a list of records

YuanZhiqian on-your-mark@REDACTED
Mon Nov 23 09:00:38 CET 2015


Hi guys,
  Glad to meet everyone here. 
  I have a little question about the lists:keysearch function that I would like to search a record in a list by using one of its fields, because lists:keysearch is tuple-oriented and records is implemented internally as tuples, so I this the function should work as well to records, and it does as I tested in the shell. ( lists:keysearch(Key, 2, List), supposing the key is in the first field )
  However I wonder if there's any side effects in this behavior, since I was taught that never access records' fields directly in the way of treating tuples. 
  P.S. There's another question here, is there any difference between lists:keyfind/3 and lists:keysearch/3? I can tell any difference between them except for the return value's formats.
MvhZhiqian 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151123/80e0e007/attachment.htm>


More information about the erlang-questions mailing list