Updated 2012-01-10 04:28:03 by RLE

Listex - List Extensions

Directions to find it at Stu

Man page:
       listex - List Extensions

       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

       A Tcl extension that provides a set of commands which per-
       form operations on lists.

       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

              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].

              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

              Uninterleave a list  into  two  or  more  lists  in
              [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}

              Returns the length of the longest list element.
              [lMaxelementLength [list a bb cccc ddd]] -> 4

See also: