andremincos
Technical User
Hello there,
The program using TCL 8.3 and was write the code below;
##########################################
proc filtering {datalist} {
set a[a $datalist]
set b[b $datalist]
foreach item $datalist {
lappend calresult [list $item [expr {$a + $b}] ]
}
set result [lsort -decreasing -index 1 -real $calresult]
foreach item $calresult {
if {[lindex $item 1] > 1.5} {
lappend outputlist $item
set print [join $outputlist ", "]
}
}
return $print
}
set writevalues [open resulted.txt w]
set outputvalues [filtering $datalist]
puts $writevalues $outputvalues
##########################################
Base on script above the Resulted below;
123 17.7992234471, 110 15.8843066333, 79 11.317966539, 58.6 8.31302015439
How to change the result by rows like this;
1, 123, 17.7992234471
2, 110, 15.8843066333
3, 79, 11.317966539
4, 58.6, 8.31302015439
Appreciate your helps.
Thanks!
The program using TCL 8.3 and was write the code below;
##########################################
proc filtering {datalist} {
set a[a $datalist]
set b[b $datalist]
foreach item $datalist {
lappend calresult [list $item [expr {$a + $b}] ]
}
set result [lsort -decreasing -index 1 -real $calresult]
foreach item $calresult {
if {[lindex $item 1] > 1.5} {
lappend outputlist $item
set print [join $outputlist ", "]
}
}
return $print
}
set writevalues [open resulted.txt w]
set outputvalues [filtering $datalist]
puts $writevalues $outputvalues
##########################################
Base on script above the Resulted below;
123 17.7992234471, 110 15.8843066333, 79 11.317966539, 58.6 8.31302015439
How to change the result by rows like this;
1, 123, 17.7992234471
2, 110, 15.8843066333
3, 79, 11.317966539
4, 58.6, 8.31302015439
Appreciate your helps.
Thanks!