How to empty a list in Tcl?
15,754
Solution 1
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.
Solution 2
How about: set lst [list]
References: list
Comments
-
SY CHEN almost 2 years
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 "".