如何从tcl列表中删除emty元素 [英] how to remove emty elements from tcl list
问题描述
%set qprList {{{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}}}
我想删除所有为空的元素.因为列表列表是我无法在单循环交互中完成的.
有什么简单的方法可以实现这一目标吗?
该列表中没有空元素.看起来空的可以视为(a)字符串"{}"或(b)包含一个元素的列表,该元素是空字符串或空列表.
package require struct::list
set non_empty [struct::list filter \
[struct::list flatten $qprList] \
{apply {{x} {expr {[string length $x] > 0}}}} \
]
hi I have following list
% set qprList {{{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} 12345 {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}} {{}}}
I want to remove all the elements which are empty. since list of list is i am not able to do it in single loop interation.
Any simple way to achieve this?
There are no empty elements in that list. The ones that seem empty can be considered as (a) a string "{}" or (b) a list with one element which is an empty string or an empty list.
package require struct::list
set non_empty [struct::list filter \
[struct::list flatten $qprList] \
{apply {{x} {expr {[string length $x] > 0}}}} \
]
这篇关于如何从tcl列表中删除emty元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!