intermission: the uniq storage option
Kimwitu has a feature that makes it quite easy to find common subexpressions:
the uniq storage option:
![[picture of a tree without node-sharing]](expr_1.gif)
(dot to generated graphs:
left non-uniq, right uniq, the edge numbers indicate a depth-first left-to-right treewalk)
- each operator call with the same arguments will yield the same result:
- common subtrees are automatically shared
- including their attributes
- can be set on per-phylum basis
To enable it is sufficient to add the following declaration:
expr {uniq} :;
and build our term (1+1) * (1+1)
expr e = Times(
Plus( Const( 1 ), Const( 1 )),
Plus( Const( 1 ), Const( 1 )) );
next overview up
Last updated at
03 February '98
by kimwitu@cs.utwente.nl