#!/usr/bin/env expect
# Replace the first list with the second list
set sFirst [lindex $argv 0]
set sSecond [lindex $argv 1]
if {$sFirst == "" || $sSecond == ""} {
puts "Input error, you should input two list!"
exit
}
set lenFirst [llength $sFirst]
set iFirst [expr $lenFirst - 1]
set lenSecond [llength $sSecond]
set iSecond [expr $lenSecond - 1]
if {$iFirst <= $iSecond} {
for {set i 0} {$i <= $iFirst} {incr i 1} {
lappend sTmp [lindex $sSecond $i]
}
set iLeft [expr $iSecond - $iFirst]
for {set i 1} {$i <= $iLeft} {incr i 1} {
lappend sTmp [lindex $sSecond [expr $iFirst + $i]]
}
set sFirst $sTmp
puts "sFirst is $sFirst"
} elseif {$iFirst > $iSecond} {
for {set i 0} {$i <= $iSecond} {incr i 1} {
lappend sTmp [lindex $sSecond $i]
}
set iLeft [expr $iFirst - $iSecond]
for {set i 1} {$i <= $iLeft} {incr i 1} {
lappend sTmp [lindex $sFirst [expr $iSecond + $i]]
}
set sFirst $sTmp
puts "sFirst is $sFirst"
# Replace the first list with the second list
set sFirst [lindex $argv 0]
set sSecond [lindex $argv 1]
if {$sFirst == "" || $sSecond == ""} {
puts "Input error, you should input two list!"
exit
}
set lenFirst [llength $sFirst]
set iFirst [expr $lenFirst - 1]
set lenSecond [llength $sSecond]
set iSecond [expr $lenSecond - 1]
if {$iFirst <= $iSecond} {
for {set i 0} {$i <= $iFirst} {incr i 1} {
lappend sTmp [lindex $sSecond $i]
}
set iLeft [expr $iSecond - $iFirst]
for {set i 1} {$i <= $iLeft} {incr i 1} {
lappend sTmp [lindex $sSecond [expr $iFirst + $i]]
}
set sFirst $sTmp
puts "sFirst is $sFirst"
} elseif {$iFirst > $iSecond} {
for {set i 0} {$i <= $iSecond} {incr i 1} {
lappend sTmp [lindex $sSecond $i]
}
set iLeft [expr $iFirst - $iSecond]
for {set i 1} {$i <= $iLeft} {incr i 1} {
lappend sTmp [lindex $sFirst [expr $iSecond + $i]]
}
set sFirst $sTmp
puts "sFirst is $sFirst"