Tree from nesting levels: Difference between revisions

Content added Content deleted
Line 1,046: Line 1,046:
Without any use cases for these trees, it's difficult to know if any implementation is correct.
Without any use cases for these trees, it's difficult to know if any implementation is correct.


Note here, that the notation used to describe these trees has some interesting consequences in the context of J:
As a side note here, the notation used to describe these trees has some interesting consequences in the context of J:


<lang J> [[[3]], 1, [[3]], 1
<lang J> [[[3]], 1, [[3]], 1
Line 1,053: Line 1,053:
|syntax error</lang>
|syntax error</lang>


On a related note, there are type issues to consider -- in J's type system, a box (which is what we would use here to represent a tree node) cannot exist in a tuple with an integer. A box can, however, contain an integer. This makes a literal interpretation of the task somewhat... difficult. We might, hypothetically, say that we are working with boxes containing integers and that it's these boxes which must achieve a specific nesting level. (If we fail to make this distinction then we wind up with a constraint which forces some tree nodes to be structured different from what appears to be the task specification. Whether or not this is an important issue is difficult to determine without use cases. So, for now, let's assume that this is an important distinction.)
But, on a related note, there are type issues to consider -- in J's type system, a box (which is what we would use here to represent a tree node) cannot exist in a tuple with an integer. A box can, however, contain an integer. This makes a literal interpretation of the task somewhat... difficult. We might, hypothetically, say that we are working with boxes containing integers and that it's these boxes which must achieve a specific nesting level. (If we fail to make this distinction then we wind up with a constraint which forces some tree nodes to be structured different from what appears to be the task specification. Whether or not this is an important issue is difficult to determine without use cases. So, for now, let's assume that this is an important distinction.)


Anyways, here's an interpretation which might be close enough to the task description:
Anyways, here's an interpretation which might be close enough to the task description: