A (Aja v0.2.0) View Source

Convenience macros to work with Aja's data structures.

Use import A to import everything, or import only the macros you need.

Link to this section Summary

Functions

Convenience macro to work with A.ExRanges (exclusive ranges).

Convenience macro to create or pattern match on A.OrdMaps.

Link to this section Functions

Convenience macro to work with A.ExRanges (exclusive ranges).

Use import A to use it, or import A, only: [{:~>, 2}].

Examples

iex> 1 ~> 5
1 ~> 5
iex> start ~> stop = 0 ~> 10
iex> {start, stop}
{0, 10}
iex> for i <- 0 ~> 5, do: "id_#{i}"
["id_0", "id_1", "id_2", "id_3", "id_4"]

Convenience macro to create or pattern match on A.OrdMaps.

Use import A to use it, or import A, only: [{:ord, 1}].

Creation examples

iex> ord(%{"一" => 1, "二" => 2, "三" => 3})
#A<ord(%{"一" => 1, "二" => 2, "三" => 3})>
iex> ord(%{a: "Ant", b: "Bat", c: "Cat"})
#A<ord(%{a: "Ant", b: "Bat", c: "Cat"})>

Pattern matching examples

iex> ord(%{b: bat}) = ord(%{a: "Ant", b: "Bat", c: "Cat"})
#A<ord(%{a: "Ant", b: "Bat", c: "Cat"})>
iex> bat
"Bat"

Replace existing keys examples

iex> ordered = ord(%{a: "Ant", b: "Bat", c: "Cat"})
iex> ord(%{ordered | b: "Buffalo"})
#A<ord(%{a: "Ant", b: "Buffalo", c: "Cat"})>
iex> ord(%{ordered | z: "Zebra"})
** (KeyError) key :z not found in: #A<ord(%{a: "Ant", b: "Bat", c: "Cat"})>