English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
If Pred(Elem) returns true for all elements Elem in the List, then return true, otherwise return false.
all(Pred, lst)
Pred - Predicate function applied to the string.
Lst - Value List.
If Pred(Elem) returns true for all elements Elem in the List, then return true, otherwise return false.
-module(helloworld). -import(lists,[all/2]). -export([start/0]). start() -> Lst1 = [1,2,3], Predicate = fun(E) -> E rem 2 == 0 end, Status = all(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.
false