TCL (Tool Command Language) Question:
Download Questions PDF

how to increment eacl element in a list?
eg: incrlist {1 2 3}
=>2 3 4

Answers:

// it works like incrlist 5 6 7 =>> 6 7 8
proc incrlist args {
set s 0
foreach s $args {
incr s 1
puts $s
}
}

//for list
proc incrlist list {
set s 0
foreach s $list {
incr s 1
puts $s
}
}

proc incrlst lst {
set lst [lreplace $lst 0 0]
lappend lst [expr [lindex $lst ([llength $lst]-1)]+1]
}
incrlst \\"3 4 5\\"

set incrlist {1 2 3}

foreach list $incrlist {

lappend final_list [incr list]


}
puts $final_list

Download TCL Interview Questions And Answers PDF

Previous QuestionNext Question
How TCL works?How to run a package in tcl?