Example:
This code will print:Tensor tensor = Tensors.parse("Cos[a+b+Sin[x]]"); TensorIterator iterator = new TreeTraverseIterator(tensor); TraverseState state; while ((state = iterator.next()) != null) System.out.println(state + " " + iterator.depth() + " " + iterator.current());
@author Dmitry Bolotin @author Stanislav PoslavskyEntering Cos[a+b+Sin[y*c+x]] Entering a+b+Sin[y*c+x] Entering a Leaving a Entering b Leaving b Entering Sin[y*c+x] Entering y*c+x Entering y*c Entering y Leaving y Entering c Leaving c Leaving y*c Entering x Leaving x Leaving y*c+x Leaving Sin[y*c+x] Leaving a+b+Sin[y*c+x] Leaving Cos[a+b+Sin[y*c+x]]
|
|
|
|