use List::Util 'first'; print "ok\n" if first {$_ eq $x} @list; grep() will find all the elements that match... in a large list this may waste time. first() will return true as soon as the element is found.
In Erlang, Lists are created by enclosing the values in square brackets. Following is a simple example of creating a list of numbers in Erlang.
The proplist, sometimes called the “opaque” is a persistent way of storing information between invocations to the callback. The create callback can return the proplist (an array of tuples) and will get it sent back on the next invocation.
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 structures in erlang like dict, orddict, List, tuples, tree, queue etc to use for cache program.
Example:
List = [{"A1",["ankit","sush", "Hover", "x4", "a3","nilesh","mike","erlang" | ...]}|...].
Now, I want to search for the Key A1 and search for 'mike' in the list. What is the best way to search the above List.
Please provide some examples. Atleast Pseudo for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With