Noether.List (noether v1.0.0)
Link to this section Summary
Functions
Given a list, it returns {:ok, list}
if every element of the list is different from nil or {:error, _}
. Otherwise {:error, :nil_found}
is returned.
Given a predicate, a function of arity 1, and a value, the function is applied repeatedly until the predicate applied to the value returns either nil
, false
, or {:error, _}
. The list of results is returned.
Link to this section Types
Link to this type
fun1()
Link to this section Functions
Link to this function
sequence(a)
Given a list, it returns {:ok, list}
if every element of the list is different from nil or {:error, _}
. Otherwise {:error, :nil_found}
is returned.
examples
Examples
iex> sequence([1, 2])
{:ok, [1, 2]}
iex> sequence([1, nil, 3])
{:error, :nil_found}
iex> sequence([{:ok, 1}, {:ok, 2}])
{:ok, [1, 2]}
iex> sequence([{:ok, 1}, {:error, 2}, {:ok, 3}])
{:error, 2}
iex> sequence([{:error, 1}, {:error, 2}])
{:error, 1}
Link to this function
until(p, f, a)
Given a predicate, a function of arity 1, and a value, the function is applied repeatedly until the predicate applied to the value returns either nil
, false
, or {:error, _}
. The list of results is returned.
examples
Examples
iex> until(fn a -> a < 10 end, &(&1 + 1), 0)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]