Documentation Center

  • Trial Software
  • Product Updates

output::tree

Display of trees

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

output::tree(Tree, <indentdepth, <charlist>, <Small>>)

Description

output::tree displays trees given as specially MuPAD® lists.

The first object of the list is the root of the tree. All further objects are nodes or subtrees of the tree. A subtree is again a special list (as described), and any other MuPAD object will be interpreted as node of the tree.

The elements of the tree will be printed by MuPAD, when the tree will be displayed, so it's recommended to use strings as objects or objects with a well defined display.

The return value is a string that contains all chars to display the tree. With functions print and fprintand the option Unquoted the tree can be displayed.

The parameter charlist is a list with five characters. The default value is ["|", "+", "-", „", " "]. The characters have the following meaning (described in the order of the list).

The vertical lines of the tree, the connection between vertical and horizontal line (i.e., an arm, but not the last arm), an arm (vertical line), the last connection to an arm in a subtree, a char between an arm and the description of the arm.

Examples

Example 1

output::tree displayes special nested lists as trees:

TREE := ["a1", "a2", ["b1", "b2", ["c1", "c2"], "b3"],
               ["d1", "d2", "d3"]]:
print(Unquoted, output::tree(TREE))
a1
|
+-- a2
|
+-- b1
|   |
|   +-- b2
|   |
|   +-- c1
|   |   |
|   |   `-- c2
|   |
|   `-- b3
|
`-- d1
    |
    +-- d2
    |
    `-- d3
print(Unquoted, output::tree(TREE, 3, Small)):
a1
+- a2
+- b1
|  +- b2
|  +- c1
|  |  `- c2
|  `- b3
`- d1
   +- d2
   `- d3

The chars can be defined by the user:

print(Unquoted, output::tree(TREE, 6, ["|", "|", ".", "\\", " "])):
a1
|
|.... a2
|
|.... b1
|     |
|     |.... b2
|     |
|     |.... c1
|     |     |
|     |     \.... c2
|     |
|     \.... b3
|
\.... d1
      |
      |.... d2
      |
      \.... d3

Parameters

Tree

The tree, given as a special list

indentdepth

Indent depth for each subtree

charlist

The chars that illustrate the tree structure

Options

Small

Suppresses the display of a space line between every tree entry to reduce the height of the tree

Return Values

String object to display

See Also

MuPAD Functions

Was this topic helpful?