Version 0 of ndlist

Updated 2023-09-11 20:17:04 by AMB

Building upon the object variable framework I developed and released with my vutil package, I created a pure-Tcl N-dimensional list implementation.

As an example, here are some of the ways you can manipulate ND list objects:

package require tin
tin add -auto ndlist https://github.com/ambaker1/ndlist install.tcl
tin import ndlist
matrix x {{1 2 3} {4 5 6} {7 8 9}}
$x @ 0* : --> y; # 1 2 3
$y .= {+ 6}; # 7 8 9
$y @ end := {sqrt($@.)}; # 7 8 3
$y ::= {format %0.2f $@.}; # 7.00 8.00 3.00
$y ndims 2; # 7.00 8.00 3.00
$y insert 0 {A B C} 1; # {A 7.00} {B 8.00} {C 3.00}
$y transpose; # {A B C} {7.00 8.00 3.00}
$y print; # {A B C} {7.00 8.00 3.00}

Additionally, all the ND list methods are also provided as Tcl commands for direct manipulation of ND list values, as shown below:

package require tin
tin add -auto ndlist https://github.com/ambaker1/ndlist install.tcl
tin import ndlist
set x {{1 2 3} {4 5 6} {7 8 9}}
set y [nget $x 0* :]; # 1 2 3
set y [nop 1D $y + 6]; # 7 8 9
nset y end [expr {sqrt([nget $y end])}]; # 7 8 3
set y [nmap 1D yi $y {format %0.2f $yi}]; # 7.00 8.00 3.00
set y [ninsert 2D $y 0 {A B C} 1]; # {A 7.00} {B 8.00} {C 3.00}
set y [ntranspose 2D $y]; # {A B C} {7.00 8.00 3.00}
puts $y; # {A B C} {7.00 8.00 3.00}

Github Repo: https://github.com/ambaker1/ndlist

-AMB