deep dict

A deep dictionary is a dictionary in which each each key has the same representation it would have in a standard dictionary, and each value is a deep list: It is either another deep dictionary or simple value, which is represented as a list containing only one item. Because it is often useful to assign multiple values to an entry, that one item is itself a list of values.

See Also

scripted dict
Scripting a deep dict in a manner similar to scripted list.

Description

Implementations

ycl dict deep
Provides get, merge, pretty, and set.

Description

Another way to define deep dictionary is as a deep list that represents a tree: Each value, is a branch that and may or may not have subordinate branches.

A deep dictionary can be unambiguously merged into another deep dictionary.

The key benefit of a deep dictionary is that the structure is self-describing: In contrast with a standard dictionary, it is possible to determine whether a value is a leaf node or an intermediate node. A value that is a list with more than one item is additional structure, whereas a value that is a list with only one item does not.

Unlike a standard Tcl dictionary, a deep dictionary is suitable for communicating an ordered tree without prior agreement between the parties about the exact shape of the tree.

Example:

{key 1} {{
    {value 1}
    {value 2}
}}
{key 2} {
    {key 2a} {{{value 3}}}
    {key 2b} {{
        {value 4}
        {value 5}
    }}
}