Talk:Tree from nesting levels: Difference between revisions

Line 107:
:::# the first example and the rest are not necessarily of the same type.
::: The conclusion is just that if anyone decides to try a rigorous data-typing, then they may produce output that diverges a bit from yours (extra pair of flanking brackets, or additional virtual root) I'm sure you will be able to cope with that :-) [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 19:27, 4 February 2021 (UTC)
 
:::: If one takes a position that doesn't allow one to fulfill the task, then the smart thing to do if you have been shown how to, and no doubt know what I required, is to adjust ones position or be doomed to never fulfil the requirements. I would suggest you add a small note at the beginning of your solution then supply an idiomatic solution fitting the description. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 19:57, 4 February 2021 (UTC)
::::: "''takes a position that ...''" Not me – Math :-) In more strictly typed languages, the bracket nesting you show trips a compiler error, because the type is inconsistent.
::::: But as you say – where the inconsistency of the type becomes a problem, a note in the preamble and a variant representation will be enough [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 20:21, 4 February 2021 (UTC)
:::: Considering the first level as a forest with the current wording seems fine. You do have a good point about the [] case being inconsistent though. Following the pattern <pre>[3] => [[[3]]], [2] => [[2]], [1] => [1], [] => ???</pre> then it seems like [] should map to 'nothing' instead of []. Also for the sum type in the python above, why is it between Int and None? Isn't the choice between Int and Tree? [[User:Garbanzo|Garbanzo]] ([[User talk:Garbanzo|talk]]) 03:40, 7 February 2021 (UTC)
125

edits