f::transpose (public)

 f::transpose lists

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

Transposes a matrix (a list of lists)

Parameters:
lists (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_functional_api functional_api (test acs-tcl) f::transpose f::transpose test_functional_api->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 f::choose f::choose (public) f::choose->f::transpose f::zip f::zip (public) f::zip->f::transpose

Testcases:
functional_api
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: