Consider the following python code
X = [None] X = X
This has many fun properties such as
X == X
X == X
I understand how this works from a practical standpoint, as it’s all just the same pointer.
Now, when flattening a list, we tend to convert things from
[[1, 2, 3], [[4, 5], [6, 7]], 8, 9]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
In this case, I am considering flattening to be reducing a multi-dimensional list down to a single list of only non-list elements.
In practice, flattening this list would be impossible, as it would create an infinite loop.
This may be more mathematical in nature, but I’m unsure how to put it in mathematical terms. Suppose we could flatten this list, would the result simply be the empty list?
For context, I initially got this idea by considering the list
X = [, ] X = X
It is clear to see that at each pass of flattening, the empty list that is the second element simply disappears. This lead me to think that the overall result, may be the empty list.
Could it be possible that flattening this list would theoretically produce an infinitely long list of the list itself, as in
X == [X, X, X, X, X, X, ..., X]
This is purely a fun thought exercise. Any insight and discussion on this would be appreciated.
P.S. Although I’m looking for an answer in plain terms, if anyone is more mathematically inclined, I would be interested to see how this problem could be formulated in some sort of set notation. Please feel free to point me to a relevant math exchange thread as well.
P.P.S. I would also be interested in a solid proof (not formal) to go along with the answer.