Kernel: Python 3
expression
.info(key=None)
A dictionary of facts about an expression.
The keys of the dictionary are:
length
,size
: the number of nodes in the syntax treewidth
,atom
: the number of letter occurrencesdepth
: the depth of the syntax tree (the depth of is 0, not 1)type
: the implementation typeadd
,complement
, etc.: the number of occurrences of these operators (+
,{c}
, etc.) in the expression
Arguments:
key
: if specified, return just the corresponding result.
See also:
Examples
In [1]:
In [2]:
In [3]:
{'add': 2,
'atom': 5,
'complement': 0,
'compose': 0,
'conjunction': 0,
'depth': 3,
'infiltrate': 0,
'ldivide': 0,
'length': 10,
'lweight': 0,
'mul': 1,
'one': 0,
'rweight': 0,
'shuffle': 0,
'size': 10,
'star': 1,
'transposition': 0,
'tuple': 0,
'type': 'expressionset<letterset<char_letters(ab)>, q>',
'width': 5,
'zero': 0}
In [4]:
'expressionset<letterset<char_letters(ab)>, q>'
Note that, although the expression uses a variadic product (the .
node features three children), the length corresponds to the usual definition of expressions based on binary node. Hence the tree features 9 nodes, but the length of the expression is 10. This applies to all the variadic operators.
In [5]:
10
In [6]:
3
In [7]:
In [8]:
In [9]:
{'add': 8,
'atom': 18,
'complement': 0,
'compose': 0,
'conjunction': 1,
'depth': 4,
'infiltrate': 0,
'ldivide': 0,
'length': 37,
'lweight': 0,
'mul': 2,
'one': 0,
'rweight': 0,
'shuffle': 0,
'size': 37,
'star': 2,
'transposition': 0,
'tuple': 0,
'type': 'expressionset<letterset<char_letters(ab)>, q>',
'width': 18,
'zero': 0}
In [10]:
{'add': 2,
'atom': 5,
'complement': 0,
'compose': 0,
'conjunction': 0,
'depth': 2,
'infiltrate': 0,
'ldivide': 0,
'length': 9,
'lweight': 0,
'mul': 1,
'one': 0,
'rweight': 0,
'shuffle': 0,
'size': 9,
'star': 0,
'transposition': 0,
'tuple': 0,
'type': 'expressionset<letterset<char_letters(ab)>, q>',
'width': 5,
'zero': 0}