transpose

one of the documented procedures in this installation of the ACS
Usage:
transpose   lists
What it does:
tranposes a matrix (a list of lists)
Defined in: /web/philip/tcl/ad-functional.tcl

Source code:


    set num_lists [llength $lists]
    if !$num_lists { return "" }

    for {set i 0} {$i<$num_lists} {incr i} {
	set l($i) [lindex $lists $i]
    }

    set result {}
    while {1} {
	set element {}
	for {set i 0} {$i<$num_lists} {incr i} {
	    if [null_p $l($i)] { return $result }
	    lappend element [head $l($i)]
	    set l($i) [tail $l($i)]
	}
	lappend result $element
    }

    # Note: This function takes about n*n seconds
    #       to transpose a (100*n) x (100*n) matrix.


philg@mit.edu