Taxo (Taxo v0.1.0)
View SourceTaxo is an Elixir port of the Clojure hierarchies provided by derive
and underive
.
Summary
Functions
Returns the ancestors of a given child
in the taxonomy taxo
.
Establish a parent/child relationship in taxo
between child
and parent
.
Updates :parents
, then transitively updates :ancestors
and :descendants
.
Returns the descendants of a given child
in the taxonomy taxo
.
Returns true if (= child parent), or child is directly or indirectly derived from parent.
Create a new taxonomy to store the :parents
, :ancestors
and :descendants
of
parent/child relationships, updated via derive
and underive
.
Updates :parents
, then transitively updates :ancestors
and :descendants
.
Returns the parents of a given child
in the taxonomy taxo
.
Removes a parent/child relationship in taxo
between child
and parent
.
Updates :parents
, then transitively updates :ancestors
and :descendants
.
Functions
Returns the ancestors of a given child
in the taxonomy taxo
.
## Examples
iex> Taxo.new |> Taxo.derive(:monkey, :mammal) |> Taxo.ancestors(:monkey)
MapSet.new([:mammal])
Establish a parent/child relationship in taxo
between child
and parent
.
Updates :parents
, then transitively updates :ancestors
and :descendants
.
Examples
iex> Taxo.new |> Taxo.derive(:monkey, :mammal)
%Taxo{
ancestors: %{monkey: MapSet.new([:mammal])},
parents: %{monkey: MapSet.new([:mammal])},
descendants: %{mammal: MapSet.new([:monkey])}
}
Returns the descendants of a given child
in the taxonomy taxo
.
## Examples
iex> Taxo.new |> Taxo.derive(:monkey, :mammal) |> Taxo.descendants(:mammal)
MapSet.new([:monkey])
Returns true if (= child parent), or child is directly or indirectly derived from parent.
Examples
iex> Taxo.new |> Taxo.derive(:monkey, :mammal) |> Taxo.derive(:mammal, :vertebrate) |> Taxo.is_a?(:monkey, :vertebrate)
true
iex> Taxo.new |> Taxo.derive(:monkey, :mammal) |> Taxo.derive(:mammal, :vertebrate) |> Taxo.is_a?(:vertebrate, :monkey)
false
Create a new taxonomy to store the :parents
, :ancestors
and :descendants
of
parent/child relationships, updated via derive
and underive
.
Updates :parents
, then transitively updates :ancestors
and :descendants
.
Examples
iex> Taxo.new
%Taxo{ancestors: %{}, parents: %{}, descendants: %{}}
Returns the parents of a given child
in the taxonomy taxo
.
## Examples
iex> Taxo.new |> Taxo.derive(:monkey, :mammal) |> Taxo.parents(:monkey)
MapSet.new([:mammal])
Removes a parent/child relationship in taxo
between child
and parent
.
Updates :parents
, then transitively updates :ancestors
and :descendants
.
Examples
iex> Taxo.derive(%{}, :monkey, :mammal) |> Taxo.underive(:monkey, :mammal)
%Taxo{ancestors: %{}, parents: %{}, descendants: %{}}