English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
If Pred (Elem) returns true for at least one element Elem in the List, then return true.
any(Pred,lst)
Pred −Predicate Function Applied to String
Lst −Value List
If Pred (Elem) returns true for at least one element Elem in the List, then return true.
-module(helloworld). -import(lists,[any/2]). -export([start/0]). start(), -> Lst1 = [1,2,3], Predicate = fun(E) -> E rem 2 end == 0 end, Status = any(Predicate, Lst1, io:fwrite("~w~n",[Status]).
In the above example, we first define a predicate function where each list value is passed to an anonymous function. In this function, we can see if each list value can be2Integer division.
When we run the above program, we will get the following results.
true