
- Erlang Tutorial
- Erlang - Home
- Erlang - Overview
- Erlang - Environment
- Erlang - Basic Syntax
- Erlang - Shell
- Erlang - Data Types
- Erlang - Variables
- Erlang - Operators
- Erlang - Loops
- Erlang - Decision Making
- Erlang - Functions
- Erlang - Modules
- Erlang - Recursion
- Erlang - Numbers
- Erlang - Strings
- Erlang - Lists
- Erlang - File I/O
- Erlang - Atoms
- Erlang - Maps
- Erlang - Tuples
- Erlang - Records
- Erlang - Exceptions
- Erlang - Macros
- Erlang - Header Files
- Erlang - Preprocessors
- Erlang - Pattern Matching
- Erlang - Guards
- Erlang - BIFS
- Erlang - Binaries
- Erlang - Funs
- Erlang - Processes
- Erlang - Emails
- Erlang - Databases
- Erlang - Ports
- Erlang - Distributed Programming
- Erlang - OTP
- Erlang - Concurrency
- Erlang - Performance
- Erlang - Drivers
- Erlang - Web Programming
- Erlang Useful Resources
- Erlang - Quick Guide
- Erlang - Useful Resources
- Erlang - Discussion
Erlang - all
Returns true if Pred(Elem) returns true for all elements Elem in List, otherwise false.
Syntax
all(Pred,lst)
Parameters
Pred − The predicate function which will be applied to the string.
Lst − The list of values.
Return Value
Returns true if Pred(Elem) returns true for all elements Elem in List, otherwise false.
For example
-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 in which each list value is passed to the anonymous function. In the function, each list value is seen if it is divisible by 2.
Output
When we run the above program, we will get the following result.
false
erlang_lists.htm
Advertisements