Mandrake v0.0.1 Mandrake.Logic
Mandrake logical functions.
Summary
Functions
Returns true if both functions return true
Returns the second argument if it is not nil
Returns true if one function return true
Returns a function that process onTrue or onFalse depending upon the result of the condition
Returns true if value is “”, ‘’, [], {} or %{}
Returns true if both conditions are true
Returns ! of value
Returns true if one condition is true
Functions
Returns true if both functions return true
Examples
iex> my_function = Mandrake.Logic.both(fn x -> x > 10 end, fn x -> Kernel.rem(x, 2) == 0 end)
...> my_function.(100)
true
iex> my_function.(101)
false
Returns the second argument if it is not nil.
Examples
iex> default_to_7 = Mandrake.Logic.default_to(7)
...> default_to_7.(nil)
7
iex> default_to_7.(12)
12
Returns true if one function return true
Examples
iex> my_function = Mandrake.Logic.either(fn x -> x > 10 end, fn x -> Kernel.rem(x, 2) == 0 end)
...> my_function.(100)
true
iex> my_function.(101)
true
Returns a function that process onTrue or onFalse depending upon the result of the condition.
Examples
iex> my_number = 1
...> my_function = Mandrake.Logic.ifElse(my_number <= 1, fn arg -> Mandrake.Math.inc(arg) end, fn arg -> Mandrake.Math.dec(arg) end)
...> my_function.(my_number)
2
Returns true if value is “”, ‘’, [], {} or %{}.
Examples
iex> Mandrake.Logic.is_empty([])
true
iex> Mandrake.Logic.is_empty(nil)
false
Returns true if both conditions are true.
Examples
iex> Mandrake.Logic.logic_and(1<2, 3>4)
false