View Source LogicGates.Or (Logic Gates v0.7.1)

Summary

Functions

Executes an OR gate on an input list. The list may contain either boolean values or anonymous functions that return either :ok and a boolean, or :error and a reason.

Functions

@spec exec([boolean() | (function() -> {:ok, boolean()} | {:error, any()})]) ::
  {:ok, boolean()} | {:error, binary()}

Executes an OR gate on an input list. The list may contain either boolean values or anonymous functions that return either :ok and a boolean, or :error and a reason.

An OR gate returns true if at least one of the input values evaluates to true. Otherwise it returns false.

If any input value function returns an error on evaluation, this function will return an error.

Truth table with three input values

iex> LogicGates.Or.exec([false, false, false])
{:ok, :false}

iex> LogicGates.Or.exec([false, false, true])
{:ok, :true}

iex> LogicGates.Or.exec([false, true, false])
{:ok, :true}

iex> LogicGates.Or.exec([false, true, true])
{:ok, :true}

iex> LogicGates.Or.exec([true, false, false])
{:ok, :true}

iex> LogicGates.Or.exec([true, false, true])
{:ok, :true}

iex> LogicGates.Or.exec([true, true, false])
{:ok, :true}

iex> LogicGates.Or.exec([true, true, true])
{:ok, :true}