Is it possible to get the creation order / placement order of elements in the TCL array?

Tcl arrays are great for finding tables, but they are stored as "unordered sets" in theory. Is there anyway that iterations through them in order elements are added to the array without adding additional code to track the placement order yourself?

+4
source share
1 answer

As far as I know, there is no way to return elements from an array in the order in which they were added without tracking the insertion order. The best way to get the behavior you want is to use a dictionary , not an array. the dict really preserves the insertion order and as a bonus, with which they work much better when you pass them to or from procs.

+7
source

Source: https://habr.com/ru/post/1384138/


All Articles