diff --git a/Project.toml b/Project.toml index 0f33f77..5bdc0d6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "HierarchicalUtils" uuid = "f9ccea15-0695-44b9-8113-df7c26ae4fa9" authors = ["Simon Mandlik "] -version = "1.1.0" +version = "1.2.0" [deps] DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" diff --git a/examples/expression_tree.ipynb b/examples/expression_tree.ipynb index 3b863c2..0a6f7d8 100644 --- a/examples/expression_tree.ipynb +++ b/examples/expression_tree.ipynb @@ -9,7 +9,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m environment at `~/.julia/dev/HierarchicalUtils/examples/Project.toml`\n" + "\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m environment at `~/.julia/dev/HierarchicalUtils/examples/Project.toml`\n", + "┌ Info: Precompiling HierarchicalUtils [f9ccea15-0695-44b9-8113-df7c26ae4fa9]\n", + "└ @ Base loading.jl:1278\n" ] } ], @@ -82,7 +84,9 @@ "To obtain `HierarchicalUtils` functionality, one must provide the following method/trait definitions:\n", "\n", "- `NodeType(::Type{MyType})` equal to `HierarchicalUtils.LeafNode()` in case when nodes of the given type are always leaves in the tree (in our case `Value` and `Variable`), or equal to `HierarchicalUtils.InnerNode()` in case when node of this type can have multiple (possibly zero) children.\n", - "- `children(n::MyType)` returning either a `Tuple` or `NamedTuple` of children (if children are referred to by some names/keys). For `LeafNode`s, this definition is not required.\n", + "- `children(n::MyType)` returning \"collection\" of children. If each child is identified by some key, it is possible to return either a `NamedTuple`, a `Dict` or a `Vector` of `Pair`s. For unordered children (or number indexing), return a `Tuple`, a `Vector\n", + "\n", + "For `LeafNode`s, this definition is not required.\n", "\n", "Optionally, one can provide:\n", "\n", @@ -235,15 +239,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[31m/\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m*\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[33m+\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m-\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37mx\u001b[39m" + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mx\u001b[39m" ] } ], @@ -260,15 +264,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[31m-\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[33m/\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m10\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m*\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m8\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37mz\u001b[39m" + "\u001b[34m-\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m/\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m10\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m8\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mz\u001b[39m" ] } ], @@ -303,15 +307,15 @@ { "data": { "text/plain": [ - "\u001b[31m/\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m*\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[33m+\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m-\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37mx\u001b[39m" + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mx\u001b[39m" ] }, "execution_count": 11, @@ -327,28 +331,78 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Truncating large trees" + "Truncating large trees both horizontally and vertically" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[31m/\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m*\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m⋮\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m-\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m⋮\u001b[39m" + "(vtrunc, htrunc) = (1, 1)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m⋮\u001b[39m\n", + "(vtrunc, htrunc) = (1, 2)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m⋮\u001b[39m\n", + "\u001b[34m│ ⋮\u001b[39m\n", + "(vtrunc, htrunc) = (1, 3)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m⋮\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ ⋮\u001b[39m\n", + "\u001b[34m│ ⋮\u001b[39m\n", + "(vtrunc, htrunc) = (2, 1)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m⋮\u001b[39m\n", + "(vtrunc, htrunc) = (2, 2)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m⋮\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m⋮\u001b[39m\n", + "(vtrunc, htrunc) = (2, 3)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m⋮\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mx\u001b[39m\n", + "(vtrunc, htrunc) = (3, 1)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m⋮\u001b[39m\n", + "(vtrunc, htrunc) = (3, 2)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m⋮\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m⋮\u001b[39m\n", + "(vtrunc, htrunc) = (3, 3)\n", + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m⋮\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mx\u001b[39m\n" ] } ], "source": [ - "printtree(t1; trunc=2)" + "for vtrunc in 1:3, htrunc in 1:3\n", + " @show vtrunc, htrunc\n", + " printtree(t1; vtrunc, htrunc)\n", + " println()\n", + "end" ] }, { @@ -367,22 +421,22 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[31m/ [\"\"]\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m* [\"E\"]\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[33m+ [\"I\"]\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m2 [\"J\"]\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[37my [\"K\"]\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37m5 [\"M\"]\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m- [\"U\"]\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m4 [\"Y\"]\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37mx [\"c\"]\u001b[39m" + "\u001b[34m/ [\"\"]\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m* [\"E\"]\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+ [\"I\"]\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m2 [\"J\"]\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37my [\"K\"]\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5 [\"M\"]\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m- [\"U\"]\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m4 [\"Y\"]\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mx [\"c\"]\u001b[39m" ] } ], @@ -399,7 +453,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -408,7 +462,7 @@ "\"I\"" ] }, - "execution_count": 14, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -426,18 +480,18 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\u001b[31m+\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[37my\u001b[39m" + "\u001b[34m+\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[37my\u001b[39m" ] }, - "execution_count": 15, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -455,7 +509,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -482,7 +536,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -491,7 +545,7 @@ "true" ] }, - "execution_count": 17, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -509,23 +563,23 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[31m+\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m/\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[33m+\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[36m/\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m \u001b[39m\u001b[36m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m \u001b[39m\u001b[36m└── op2: \u001b[39m\u001b[35m+\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m \u001b[39m\u001b[36m \u001b[39m\u001b[35m⋮\u001b[39m" + "\u001b[34m+\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m/\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[33m/\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m1\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[36m+\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m \u001b[39m\u001b[32m \u001b[39m\u001b[33m \u001b[39m\u001b[36m⋮\u001b[39m" ] } ], @@ -535,7 +589,7 @@ "t_golden[2,2] = t_golden;\n", "t_golden[2][2] = t_golden;\n", "t_golden.ch[2][2] = t_golden;\n", - "printtree(t_golden; trunc=5)" + "printtree(t_golden; htrunc=5)" ] }, { @@ -547,7 +601,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -565,7 +619,7 @@ " \"c\"" ] }, - "execution_count": 19, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -589,8 +643,8 @@ "\n", "- `NodeIterator(t; complete::Bool=true, order::AbstractOrder=PreOrder())` iterates over all nodes in the tree\n", "- `LeafIterator(t; complete::Bool=true, order::AbstractOrder=PreOrder())` iterates over all leaves (either nodes marked with `LeafNode()` trait or `InnerNode()` with zero children)\n", - "- `TypeIterator(t, type::Type; complete::Bool=true, order::AbstractOrder=PreOrder())` iterates over all nodes of the given type\n", - "- `PredicateIterator(t, f::Function; complete::Bool=true, order::AbstractOrder=PreOrder())` iterates over all nodes, such that `f(n)` returns true" + "- `TypeIterator(type::Type, t; complete::Bool=true, order::AbstractOrder=PreOrder())` iterates over all nodes of the given type\n", + "- `PredicateIterator(f::Function, t; complete::Bool=true, order::AbstractOrder=PreOrder())` iterates over all nodes, such that `f(n)` returns true" ] }, { @@ -602,24 +656,24 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\u001b[31m/\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m*\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[33m+\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m-\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37mx\u001b[39m" + "\u001b[34m/\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m2\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m-\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m4\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mx\u001b[39m" ] }, - "execution_count": 20, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -630,24 +684,24 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\u001b[31m-\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[32m+\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[33m/\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m├── op1: \u001b[39m\u001b[37m10\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m│ \u001b[39m\u001b[33m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", - "\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[32m*\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m8\u001b[39m\n", - "\u001b[31m \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37mz\u001b[39m" + "\u001b[34m-\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[31m+\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[32m/\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m├── op1: \u001b[39m\u001b[37m10\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m│ \u001b[39m\u001b[32m└── op2: \u001b[39m\u001b[37my\u001b[39m\n", + "\u001b[34m│ \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37m5\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[31m*\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m├── op1: \u001b[39m\u001b[37m8\u001b[39m\n", + "\u001b[34m \u001b[39m\u001b[31m└── op2: \u001b[39m\u001b[37mz\u001b[39m" ] }, - "execution_count": 21, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -658,18 +712,18 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\u001b[31m+\u001b[39m\n", - "\u001b[31m├── op1: \u001b[39m\u001b[37mx\u001b[39m\n", - "\u001b[31m└── op2: \u001b[39m\u001b[37my\u001b[39m" + "\u001b[34m+\u001b[39m\n", + "\u001b[34m├── op1: \u001b[39m\u001b[37mx\u001b[39m\n", + "\u001b[34m└── op2: \u001b[39m\u001b[37my\u001b[39m" ] }, - "execution_count": 22, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -680,7 +734,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 38, "metadata": {}, "outputs": [ { @@ -690,15 +744,15 @@ " /\n", " *\n", " +\n", - " 2\n", - " y\n", - " 5\n", + " \u001b[37m2\u001b[39m\n", + " \u001b[37my\u001b[39m\n", + " \u001b[37m5\u001b[39m\n", " -\n", - " 4\n", - " x" + " \u001b[37m4\u001b[39m\n", + " \u001b[37mx\u001b[39m" ] }, - "execution_count": 23, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -709,21 +763,21 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5-element Array{Expression,1}:\n", - " 2\n", - " y\n", - " 5\n", - " 4\n", - " x" + " \u001b[37m2\u001b[39m\n", + " \u001b[37my\u001b[39m\n", + " \u001b[37m5\u001b[39m\n", + " \u001b[37m4\u001b[39m\n", + " \u001b[37mx\u001b[39m" ] }, - "execution_count": 24, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1381,15 +1435,15 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.4.1", + "display_name": "Julia 1.5.0", "language": "julia", - "name": "julia-1.4" + "name": "julia-1.5" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.4.1" + "version": "1.5.0" } }, "nbformat": 4, diff --git a/src/definitions.jl b/src/definitions.jl index 86c36fb..fba6041 100644 --- a/src/definitions.jl +++ b/src/definitions.jl @@ -1,4 +1,3 @@ -# TODO define this implicitly? macro hierarchical_dict() return esc( quote