[Solved] Addition of 2 columns based on previous column


You didn’t ask for Tcl code, but here’s one way to do it. It could be prettier, but it works.

set data {
A1  1   2   a1
B1  3   4   b1
C1  5   6   c1
}

set ns {}
foreach {- a b -} $data {
    lappend ns $a $b
}

set a 0
set xs 1
foreach n [lrange $ns 1 end] {
    lappend xs [incr a $n]
}

foreach {a b} $xs r {a b c} {
    puts "[string toupper $r]1\t$a\t$b\t${r}1"
}

0

solved Addition of 2 columns based on previous column