How do you empty a list in Tcl efficiently?
I have tried using lreplace to empty a list, for example:
set lst "a b c d e"
lreplace $lst 0 [[llength $lst] - 1] # replace all content in the list with "".
The empty string is an efficient value to use.
set lst {}
You can use [list] with no arguments instead of {}; that compiles to the same thing.
How about: set lst [list]
References: list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With