How can I make function to search for a word in list and return true if word in list.
Example :
find(string) ->
List = ["bye", "hello", "hi"],
case string in List of
true ->
true;
_ ->
false
end.
find("hi there, how are you today?").
And the text is : "hi there, How are you today?"
it should return true cuz hi in list.
1> F = fun(String) -> List = ["bye", "hello", "hi"], lists:any(fun(S) -> lists:member(S, List) end, string:tokens(String, " ,.?!")) end.
#Fun<erl_eval.6.54118792>
2> F("hi, what did you tried so far?").
true