View Source Algae.Tree.Rose (Algae v1.3.2-doma)

A tree with any number of nodes at each level

examples

Examples

%Algae.Tree.Rose{
  rose: 42,
  forest: [
    %Algae.Tree.Rose{
      rose: "hi"
    },
    %Algae.Tree.Rose{
      forest: [
        %Algae.Tree.Rose{
          rose: 0.4
        }
      ]
    },
    %Algae.Tree.Rose{
      rose: "there"
    }
  ]
}

Link to this section Summary

Functions

Create a simple Algae.Rose tree, with an empty forest and one rose.

Wrap another tree around an existing one, relegating it to the forest.

Create an Algae.Rose tree, passing a forest and a rose.

Link to this section Types

@type forest() :: [t()]
@type rose() :: any()
@type t() :: %Algae.Tree.Rose{forest: [t()], rose: any()}

Link to this section Functions

Link to this function

%Algae.Tree.Rose{}

View Source (struct)

Create a simple Algae.Rose tree, with an empty forest and one rose.

examples

Examples

iex> new(42)
%Algae.Tree.Rose{
  rose: 42,
  forest: []
}
@spec layer(t(), rose()) :: t()

Wrap another tree around an existing one, relegating it to the forest.

examples

Examples

iex> 55
...> |> new()
...> |> layer(42)
...> |> layer(99)
...> |> layer(6)
%Algae.Tree.Rose{
  rose: 6,
  forest: [
    %Algae.Tree.Rose{
      rose: 99,
      forest: [
        %Algae.Tree.Rose{
          rose: 42,
          forest: [
            %Algae.Tree.Rose{
              rose: 55
            }
          ]
        }
      ]
    }
  ]
}
Link to this function

new(rose \\ nil, forest \\ [])

View Source
@spec new(any(), [t()]) :: t()
@spec new(rose(), forest()) :: t()

Create an Algae.Rose tree, passing a forest and a rose.

examples

Examples

iex> new(42, [new(55), new(14)])
%Algae.Tree.Rose{
  rose: 42,
  forest: [
    %Algae.Tree.Rose{rose: 55},
    %Algae.Tree.Rose{rose: 14}
  ]
}
Link to this function

new_partial(rose, forest)

View Source