Note that there are some explanatory texts on larger screens.

plurals
  1. PONavigate manually with a cursor through nested lists by only providing "left()" and "right()" as commands?
    text
    copied!<p>Eventhough I write in python I think the abstract concept is more interesting to me and others. So pseudocode please if you like :)</p> <p>I have a list with items from one of my classes. Lets do it with strings and numbers here, it really doesn't matter. Its nested to any depth. (Its not really a list but a container class which is based on a list.) </p> <p><strong>Example</strong>: <em>[1, 2, 3, ['a', 'b', 'c'] 4 ['d', 'e', [100, 200, 300]] 5, ['a', 'b', 'c'], 6]</em></p> <p>Note that both ['a', 'b', 'c'] are really the same container. If you change one you change the other. The containers and items can be edited, items inserted and most important containers can be used multiple times. To avoid redundancy its not possible to flatten the list (I think!) because you loose the ability to insert items in one container and it automatically appears in all other containers.</p> <p><strong>The Problem:</strong> For the frontend (just commandline with the python "cmd" module) I want to navigate through this structure with a cursor which always points to the current item so it can be read or edited. The cursor can go left and right (users point of view) and should behave like the list is not a nested list but a flat one. </p> <p>For a human this is super easy to do. You just pretend that in this list above the sublists don't exist and simply go from left to right and back.</p> <p>For example if you are at the position of "3" in the list above and go right you get 'a' as next item, then 'b', 'c', and then "4" etc. Or if you go right from the "300" you get the "5" next.</p> <p>And backwards: If you go left from "6" the next is 'c'. If you go left from "5" its "300".</p> <p>So how do I do that in principle? I have one approach here but its wrong and the question is already so long that I fear most people will not read it :(. I can post it later.</p> <p>P.S. Even if its hard to resist: The answer to this question is not "Why do you want to do this, why do you organize your data this way, why don't you [flatten the list| something out of my imagination] first? The problem is exactly what I've described here, nothing else. The data is structured by the nature of the problem this way.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload