View Source ExAequoBase.Fn (ExAequoBase v0.1.3)
Functional Helpers
Summary
Functions
Runs the first function that does not return nil
Types
@type atoms() :: [atom()]
@type binaries() :: [binary()]
@type error_t() :: {:error, binary()}
@type error_t(t) :: {:error, t}
@type maybe(t) :: nil | t
@type natural() :: non_neg_integer()
@type numbered(t) :: {t, number()}
@type numbered_lines_t() :: [numbered_line_t()]
@type ok_t() :: {:ok, any()}
@type ok_t(t) :: {:ok, t}
@type zero_fn_t() :: (-> any())
@type zero_fn_t(t) :: (-> t)
Functions
Runs the first function that does not return nil
iex(1)> fns = [
...(1)> fn -> nil end,
...(1)> fn -> 42 end,
...(1)> fn -> "not reached" end
...(1)> ]
...(1)> select(fns)
42
Returns an error if no function matched
iex(2)> select([fn -> nil end])
{:error, "No functions matched"}
Even if the input was empty
iex(3)> select([])
{:error, "No functions matched"}