Talk:Tree from nesting levels: Difference between revisions
m
→Simplified presentation of a consistent recursive data structure
Line 70:
[[User:Hout|Hout]] ([[User talk:Hout|talk]]) 12:23, 4 February 2021 (UTC)
We can obtain a self-consistent representation of these forests as lists of tuples, in which the first value is a kind of sum type – in Python terms (
▲We can obtain a self-consistent representation of these forests as lists of tuples, in which the first value is a kind of sum type (Int or None), and the second value is itself a (possibly empty) forest:
A consistent recursive data structure:
<pre>Node (None|Int) :: ((None|Int), [Node])</pre>
<lang python>(None, [])
(None, [(1, [(2, [(None, [(4, [])])])])])
|