Algo.Helpers (Algo v0.1.0)

Copy Markdown View Source

Shared internal helpers for Algo modules.

Summary

Functions

Returns the module that implements map-like operations for an associative value.

Functions

module(map)

@spec module(any()) :: {:ok, Map | Keyword} | :error

Returns the module that implements map-like operations for an associative value.

Maps return {:ok, Map} and keyword lists return {:ok, Keyword}. Other values return :error.

Examples

iex> Algo.Helpers.module(%{a: 1})
{:ok, Map}

iex> Algo.Helpers.module(a: 1)
{:ok, Keyword}

iex> Algo.Helpers.module([1, 2, 3])
:error