Talk:Tree from nesting levels: Difference between revisions

/* multiple level 1 siblings implies *lists* of trees (forests), rather than single 'trees'
(just an abstract idea)
(/* multiple level 1 siblings implies *lists* of trees (forests), rather than single 'trees')
Line 49:
<div style="clear:both"></div>
:::(The tree traversal in no way has to be recursive, of course) --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 22:49, 2 February 2021 (UTC)
 
==The target outputs shown clash with the task description==
 
There's a clash here between the description's talk of 'a Tree' (suggesting a single root), and the examples of target output, which show forests (lists of trees), with '''multiple nodes at level 1'''.
 
The existence of multiple level 1 siblings tells us that each of these trees has a virtual root (parent of the level one siblings) which might be called '''level 0'''. (See the Nothing root in the Haskell tree diagrams)
 
In which case, the outputs shown are not, in fact, self-consistent ...
 
Your first output example `[]` is indeed a '''tree''' (the virtual root, with no descendants).
 
Those that follow, however, show '''lists''' of trees ('forests' if you like).
 
If you really want each output example to have the same consistent type, and you want that to be "tree", in each case, rather than "tree" in one case, and "list of trees" in the others, then from the second example onwards, you really need an additional pair of flanking brackets.
 
i.e.
<pre>list of trees -> single tree
[1, [2, [[4]]]] -> [[1, [2, [[4]]]]]</pre>
[[User:Hout|Hout]] ([[User talk:Hout|talk]]) 12:23, 4 February 2021 (UTC)
9,655

edits