Erlang – Logical Operators

Erlang Logical Operators

Following are the logical operators available in Erlang.

OperatorDescriptionExample
orThis is the logical “and” operatortrue or true will give true
andThis is the logical “or” operatorTrue and false will give false
notThis is the logical “not” operatornot false will give true
xorThis is the logical exclusive “xor” operatorTrue xor false will give true

The following code snippet shows how the various operators can be used.

Example

-module(helloworld). 
-export([start/0]). 

start() -> 
   io:fwrite("~w~n",[true or false]),  
   io:fwrite("~w~n",[true and false]), 
   io:fwrite("~w~n",[true xor false]), 
   io:fwrite("~w~n",[not false]).

The output of the above program will be −

Output

true
false
true
true

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply