Depth of nested list
|
09-11-2023, 12:55 PM
Post: #9
|
|||
|
|||
RE: Depth of nested list
(09-09-2023 05:22 PM)John Keith Wrote: A couple of vague ideas here: My first thought was the same as your first suggestion above. Then I (perhaps foolishly) wanted to see what it would take to use the second approach instead, as I thought it might be an opportunity to try a recursive implementation. The following visits each object in the list given as an argument, and tracks the depth as it dives into embedded lists. After visiting each embedded object, it simply outputs the deepest level it encountered: Code: \<< I have to say that this ended up being one of the ugliest RPL programs I've created in a while. I promise that was not intentional -- it just ended up being that way as I tried to save a few bytes here and there. Using IFTE instead of the traditional IF ... THEN ... ELSE ... END can definitely save a few bytes, especially when combined with the use of lists and null-tagged objects instead of executable objects. But all of that comes at a price, both in terms of readability and the quirkiness of using identifiers in lists. Unfortunately the compiled locals make it look even more cluttered. But it works as intended! |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Depth of nested list - rickster - 09-08-2023, 11:08 PM
RE: Depth of nested list - Joe Horn - 09-09-2023, 12:07 AM
RE: Depth of nested list - John Keith - 09-09-2023, 10:34 AM
RE: Depth of nested list - DavidM - 09-09-2023, 11:33 AM
RE: Depth of nested list - John Keith - 09-09-2023, 03:00 PM
RE: Depth of nested list - DavidM - 09-09-2023, 04:15 PM
RE: Depth of nested list - Albert Chan - 09-09-2023, 11:59 AM
RE: Depth of nested list - John Keith - 09-09-2023, 05:22 PM
RE: Depth of nested list - DavidM - 09-11-2023 12:55 PM
RE: Depth of nested list - DavidM - 09-11-2023, 03:28 PM
RE: Depth of nested list - Gilles - 09-11-2023, 04:05 PM
RE: Depth of nested list - Werner - 09-11-2023, 05:46 PM
|
User(s) browsing this thread: 1 Guest(s)