使用数组get后,如何删除TCL中的索引

Lum*_*mpi 1 arrays list tcl

我有一个用数组完成的proc.要返回它,我使用"array get"来检索列表.但是这个列表不仅包含我的数组,还包含它们的索引:

所以我的数组[ a b c d ] 变成了一个列表{ 0 a 1 b 2 c 3 d }

如何在不打扰列表顺序的情况下摆脱这些索引号?

Don*_*ows 5

一些选项,除了使用foreach:

# [array get] actually returns a dictionary
puts [dict values $list]
Run Code Online (Sandbox Code Playgroud)
# Could do this too
set entrylist {}
dict for {- entry} $list {
    lappend entrylist $entry
}
puts $entrylist
Run Code Online (Sandbox Code Playgroud)

Tcl 8.6中有更多可能性:

puts [lmap {- entry} $list {set entry}]
Run Code Online (Sandbox Code Playgroud)

(还有一个dict map,但在这里没用.)

我喜欢dict values......