Functional coverage tree: Difference between revisions
m
→{{header|J}}
m (→{{header|J}}) |
m (→{{header|J}}) |
||
Line 178:
<lang J>unrooted=: ([:;@(({.@[,(+}.)~)&.> [: +/\1,_1}.#@>) <@(_1,$:@}.);.1)^:(1<#)
parent=: unrooted level
parent_cover=: (] (1}.~.parent)}~ 1}. * %&(
<code>unrooted</code> translates indentation information to a [[Tree_traversal#J:_Alternate_implementation|parent tree structure]]. However, the limitations of recursion require we distinguish the parent node from its children, so we use _1 to denote the parent node of the recursive intermediate result unrooted trees. (This works well with using arithmetic to adjust sub-tree indices based on the lengths of preceding sub-trees.)
|