How to Search for an item in a List in Erlang?

后端 未结 7 1843
抹茶落季
抹茶落季 2021-01-04 07:56

I am writing a cache gen-server for the company Use. I am wondering how to search an item from the list as I want the cost of the search for comparing various data structure

7条回答
  •  死守一世寂寞
    2021-01-04 08:34

    You can also use any from http://erlang.org/doc/man/lists.html#any-2

    lists:any(fun(X) -> X == <<"yourthing">> end, YourList)
    

    will return true if found or false otherwise.

提交回复
热议问题