Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A dynamic tool that helps visualize the structure of an expression
| ResourceFunction["ExpressionViewer"][expr] produces a dynamic graphical view of an expression expr to help explore its structure. | 
ExpressionViewer helps inspect the nested structure of any valid expression:
| In[1]:= | ![ResourceFunction["ExpressionViewer"][{1 + 1, bar["a", "b"]}]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/672b804a8719809a.png) | 
| Out[1]= |  | 
Click the part of the expression you want to address to print the part specification:
| In[2]:= | ![ResourceFunction["ExpressionViewer"][{1 + 1, bar["a", "b"]}]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/7970914cb6600e40.png) | 
| Out[2]= |  | 
Visually find the position of any part of a deeply nested expression by clicking it:
| In[3]:= | ![expr = {1 -> 2, <|
    "3" -> {1 -> 2, <|"3" -> 4, "5" -> 6|>, {1, <|"3" -> 4, "5" -> 6|>,
        7, 3}}, "5" -> 6|>, {1, <|"3" -> 4, "5" -> 6|>, {"findme", 2, 3}, 3}};
ResourceFunction["ExpressionViewer"][expr]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/4d67504eaa541927.png) | 
| Out[4]= |  | 
After you click "findme" in the previous cell, the position is printed and copied to the clipboard, and then Extract can be used:
| In[5]:= | ![Extract[expr, {3, 3, 1}]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/74a7c43f8f08715c.png) | 
| Out[5]= |  | 
Supply a custom ColorFunction that colors the parts based on depth:
| In[6]:= | ![expr = {1 -> foo[2], bar["a", "b"]};
ResourceFunction["ExpressionViewer"][expr, ColorFunction -> (RGBColor[0, 1, 0, 0.2] &)]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/3a436a33c8c492fe.png) | 
| Out[7]= |  | 
Plot with built-in gradients like "DeepSeaColors":
| In[8]:= | ![expr = Nest[f[#] &, x, 10];
ResourceFunction["ExpressionViewer"][expr, ColorFunction -> ColorData["DeepSeaColors"]]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/6b35cb4ab1824c29.png) | 
| Out[9]= |  | 
Make a funky plot with the "Hue" style:
| In[10]:= | ![expr = {1 -> 2, <|
    "3" -> {1 -> 2, <|"3" -> 4, "5" -> 6|>, {1, <|"3" -> 4, "5" -> 6|>,
        7, 3}}, "5" -> 6|>, {1, <|"3" -> 4, "5" -> 6|>, {1, 2, 3}, 3}};
ResourceFunction["ExpressionViewer"][expr, ColorFunction -> "Hue"]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/63e02b277dc6cd50.png) | 
| Out[11]= |  | 
Set the margins for the frames:
| In[12]:= | ![expr = Nest[(1 + #)^2 &, x, 3];
Manipulate[
 ResourceFunction["ExpressionViewer"][expr, FrameMargins -> m], {m, 0,
   10}]](https://www.wolframcloud.com/obj/resourcesystem/images/f74/f7418ad5-d6c5-4699-8da9-c7006915b6f9/143db61fda60a47f.png) | 
| Out[13]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License