How Do I convert the below string/list to a list whose first element is 1-81 second element is 81-162 3rd element us 162-243 using tcl
{} {} {1 -81} { } {81 -162} { } {162 -243} { } {243 -324} { } {324 -405} { } {405 -486} { } {486 -567} { } {567 -648} { } {648 -729} { } {729 -810} { } {810 -891} { } {891 -972} { } {972 -1053} { } {1053 -1134} { }
Thanks
If you just want to filter out empty list elements, the obvious thing to do is:
Note that you don’t need to do the
[string trim]if you’re sure all empty elements really are empty and don’t contain whitespace (meaning{}instead of possibly{ }). But your example contain both empty elements and whitespace so you need to do the string trim.Alternatively you can use a regular expression to test:
You can however do the above in a single line using lsearch: