An alternative approach, would be to use a recursive loop, and to calculate each row by using the values calculated for the previous row. This can become a little involved as you need to create a copy of the “tree” value from the previous row.
Last year I built set of components which I called the “Cumulative Framework Components” which can be used as a template for this kind of processing.
These components automatically provide you with the output for the previous row within a recursive loop, and the following workflow also provides a solution to the problem you have posed, without using either Column Expressions (or Java Snippet), which are the two scripting nodes that can perform cumulative calculations.
For more info on my cumulative framework components, see here:
Background notes: In both the Column Expressions workflow and the Cumulative Framework workflow, the same set of rules for deriving the tree apply:
Rules:
rule | description |
---|---|
1(a) | If there is no previous row, set the “current working tree” to “0” |
1(b) | otherwise set the “current working tree” to the tree from the previous row |
(the “current working tree” is the tree value that we are working on for the current row) | |
2 | Taking the level value as N, set the “current working tree” up to block N (by counting the blocks separated by “.”, and assuming an imaginary “.” on the end of final block ). Remove surplus numeric blocks (if any) |
3 | If the current working tree has fewer blocks than required for the current level (N), append “.0” to it. |
4 | Increment the final numeric block in current working tree by 1. This becomes the new tree for this row. |
In this way given the levels:
level | becomes | according to rule | transformations |
---|---|---|---|
1 | 1 | 1(a),2,4 | nothing → 0 → 0 → 1 |
2 | 1.1 | 1(b),2,3,4 | 1 → 1 → 1 → 1.0 → 1.1 |
2 | 1.2 | 1(b),2,4 | 1.1 → 1.1 → 1.2 |
2 | 1.3 | 1(b),2,4 | 1.2 → 1.2 → 1.3 |
3 | 1.3.1 | 1(b),2,3,4 | 1.3 → 1.3 → 1.3.0 → 1.3.1 |
4 | 1.3.1.1 | 1(b),2,3,4 | 1.3.1 → 1.3.1 → 1.3.1.0 → 1.3.1.1 |
2 | 1.4 | 1(b),2,4 | 1.3.1.1 → 1.3 → 1.4 |
1 | 2 | 1(b),2,4 | 1.4 → 1.4 → 1 → 2 |
2 | 2.1 | 1(b),2,4 | 2 → 2 → 2.0 → 2.1 |
and so on.