f::transpose (public)

 f::transpose lists

Defined in packages/acs-tcl/tcl/ad-functional-procs.tcl

tranposes a matrix (a list of lists)

Parameters:
lists

Partial Call Graph (max 5 caller/called nodes):
%3 f::choose f::choose (public, deprecated) f::transpose f::transpose f::choose->f::transpose f::zip f::zip (public) f::zip->f::transpose f::head f::head (public) f::transpose->f::head f::null_p f::null_p (public) f::transpose->f::null_p f::tail f::tail (public) f::transpose->f::tail

Testcases:
No testcase defined.
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.
    #       Pretty fast, don't you think? :)
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: