获取结构数组中的索引 [英] Get the index in a structure array
本文介绍了获取结构数组中的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个在tcl中的结构数组
I have this structure array which is in tcl
A = {1 2 3} {4 5 6} {7 8 9} {1 4 10}
A={1 2 3} { 4 5 6 } {7 8 9} {1 4 10}
我想获取结构索引,该索引包含数字4(应为2,在A中为4);我该怎么办?
I would like to get the structure indices which contain the number 4 which should be 2 , and 4 in A; how could I do it?
同样,在我能够获得该索引之后,我想删除那些结构,以便
Also after i was able to get that indices , i'd like to remove those structures so that
A = {1 2 3} {7 8 9}
A={1 2 3}{7 8 9}
我该怎么做?
谢谢!
推荐答案
[lmap]
可以提供帮助. [continue]
允许您跳过以下项目:
[lmap]
can help with that. [continue]
allows you to skip the item:
set A {{1 2 3} {4 5 6} {7 8 9} {1 4 10}}
set B [lmap x $A {
if {[lsearch -exact $x 4] >= 0} {
continue
} else {
set x
}
}]
puts $B
这篇关于获取结构数组中的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文