Erlang-logical-operators

提供:Dev Guides
2020年6月23日 (火) 00:47時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

アーラン-論理演算子

Erlangで使用できる論理演算子は次のとおりです。

Operator Description Example
or This is the logical “and” operator true or true will give true
and This is the logical “or” operator True and false will give false
not This is the logical “not” operator not false will give true
xor This is the logical exclusive “xor” operator True xor false will give true

次のコードスニペットは、さまざまな演算子の使用方法を示しています。

-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]).

上記のプログラムの出力は次のようになります-

出力

true
false
true
true