Rotate a list. (Creates and returns a new list.) proc lrotate {xs {n 1}} { if {!$n} {return $xs} if {$n<0} {return [lrotate $xs [expr {[llength $xs]+$n}]]} foreach x [lassign $xs y] { lappend ys $x } lappend ys $y lrotate $ys [incr n -1] } By default, rotates a list ''left'' by one element (moving the head to the tail). Examples: % lrotate {1 2 3 4 5} 2 3 4 5 1 % lrotate {1 2 3 4 5} -1 5 1 2 3 4 % lrotate {1 2 3 4 5} 2 3 4 5 1 2 % lrotate {1 2 3 4 5} 0 1 2 3 4 5 I'm sure someone can come up with a better implementation...