简体   繁体   中英

Print contents of several arrays in columns sorted by the key in tcl

I have several arrays with same key range. I am trying to print them as columns sorted by key value.

For eg: binA($i), binB($i), binC($i) I:1-100

Expected output:
i A B C
1 binA(1) binB(1) binC(1)
2
3
....
100 .....

Can anyone please show me how to do this in TCL?

untested

set bins {A B C}

foreach i [lsort -integer [array names binA]] {
    set fields [list $i]
    foreach bin $bins {
        lappend fields [set bin${bin}($i)]
    }
    puts [join $fields]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM