Listex - List Extensions Directions to find it at [Stu] Man page: NAME listex - List Extensions SYNOPSIS package require Tcl package require listex 0.1 namespace import ::listex::* lPluck list varlist ?indexlist? lDivide list divindex varleft varright lDivideAtStr list varleft varright ?divstr? lUninterleave list args lMaxElementLength list DESCRIPTION A Tcl extension that provides a set of commands which per- form operations on lists. COMMANDS lPluck Select elements from list, setting variables in caller, with optional list of indices. [lPluck {a b c d} {x y z}] -> x=a,y=b,z=c [lPluck {a b c d} {x y z} {3 0 1}] -> x=d,y=a,z=b lDivide Divides a list into two lists at index specified by index, setting variables in caller. Left var receives [lrange $list 0 $index], right var receives [lrange $list $index+1 end]. Returns [lrange $list 0 $index]. lDivideAtStr Divides a list into two lists at list element con- taining divider string divstr (default --). List element containing divider string is discarded. [lsearch -glob] is used so divstr can contain glob characters. Returns 1 if divstr was found in list, 0 otherwise. Original use: argument processing. This table shows how it's all supposed to work (with default divstr --): list left right return -------------------------------------------------- {a b c -- d e f} {a b c} {d e f} 1 {a b c} {} {a b c} 0 {a b c --} {a b c} {} 1 {-- a b c} {} {a b c} 1 {--} {} {} 1 {} {} {} 0 lUninterleave Uninterleave a list into two or more lists in caller. [lUninterleave {a b c d e f} x y] -> x={a c e}, y={b d f} [lUninterleave {a b c d e f} x y z] -> x={a d}, y={b e},z={c f} lMaxelementLength Returns the length of the longest list element. [lMaxelementLength [list a bb cccc ddd]] -> 4 See also: * [Chart of proposed list functionality] <>Suggestions | Command | Data Structure