Depth of nested list
|
09-09-2023, 05:22 PM
Post: #8
|
|||
|
|||
RE: Depth of nested list
A couple of vague ideas here:
Convert to string, initialize a counter, loop through the string and increment the counter when a left brace is encountered, and decrement when a right brace is encountered. The maximum value is the depth of nesting. Would be slow for large lists. Unpack the list, check the type of each item, if a list is encountered, unpack it and so on, keeping track of max. depth. Probably faster since one rarely encounters lists with nesting more than three levels deep. |
|||
« 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)