Very clever.
Yes, I agree this is probably better handled in a more conventional and powerful programming language. I was really just messing around & discovered this issue. It seems lists are really designed primarily for user interactions, & they don’t have the methods you’d expect with a more general purpose list object.