View Source LogicGates.And (Logic Gates v0.1.0)
Summary
Functions
Executes an AND 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 AND 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 AND gate returns true if all of the input values evaluate 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.And.exec([false, false, false])
{:ok, :false}
iex> LogicGates.And.exec([false, false, true])
{:ok, :false}
iex> LogicGates.And.exec([false, true, false])
{:ok, :false}
iex> LogicGates.And.exec([false, true, true])
{:ok, :false}
iex> LogicGates.And.exec([true, false, false])
{:ok, :false}
iex> LogicGates.And.exec([true, false, true])
{:ok, :false}
iex> LogicGates.And.exec([true, true, false])
{:ok, :false}
iex> LogicGates.And.exec([true, true, true])
{:ok, :true}