
Meine lieben Users of the one-and-only right Pocket Calculator,

It's a pity, than one cann't use variables in a matrix, so I have made
some programs to emulate that in list-objects. I call them "list_arrays"

A normal HP28 array has a form of:
 
                [[ -1 2 -3 ]
                 [ 4 5 9 ]
                 [ 4 5.1 9 ]
                 [ 0 .34 1e99 ]]

My list_array has a form of:

               {{ 12 'x1' 'prg2' -8.6 }
                { 1 2 #3d }                
                { (5,3) -1.3 'do_it' }                
                { 'yes' 'no' 4.6e-55 }}

A condition is, that every row must have the same number of elements!



Now some programs to handle with this new data type:

LTRN is the same program as TRN for arrays: it swaps the row/column-numbers

LTRN
<< DUP SIZE                      ! number of rows
   OVER 1 GET SIZE               ! number of columns
   -> a n m <<
     1 m FOR i                   ! loop of columns
       1 n FOR j                 ! loop of rows
         a j GET                 ! get a row 
         i GET                   ! get an element of this row
       NEXT
       n ->LIST                  ! form a new (transponied) row
     NEXT
     m ->LIST                    ! form the new (transponied) list
  >>
>>



A<-->L transforms an array in a list_array and return. You need my REP as
sub-progrogram:

A<-->L 
<< ->STR                         ! into a string
   "[" "{"                       ! the open-delimiters
   3 PICK OVER                   ! the string and "{"   
   IF POS THEN SWAP END          ! if it's a list then swap the delimiters
   ROT REP                       ! replace the delimiters with the counterpart
   "]" "}"                       ! the close-delimiters
   3 PICK OVER                   ! the string and "}"   
   IF POS THEN SWAP END          ! if it's a list then swap the delimiters
   ROT REP                       ! replace the delimiters with the counterpart
   STR->                         ! out of the string
>>


For those users without my REP program:

A->L                             ! transform an array to a list_array
<< DUP SIZE                      ! a list of the array dimension
   DUP SIZE                      ! kind of the array
   IF 1 == THEN 1 + END          ! if it is a vector then add 1 to size
   -> a s                        ! array , size
   << 1 s 1 GET                  ! number of rows
      FOR i                      ! ->loop 
        1 s 2 GET                ! number of columns
        FOR j                    ! ->loop
          a { i j } GET          ! extract (transponied) element
        NEXT
        s 2 GET                  ! number of columns
        ->LIST                   ! form a row
      NEXT
      s 1 GET                    ! number of rows
      ->LIST                     ! form the list      
   >>
>>


L->A                             ! transform a list_array to an array 
<< DUP SIZE -> a s               ! list and size
  << 1 s FOR i                   ! loop from 1 to size of list
       a i GET                   ! extract a row
       LIST-> DROP               ! out of the list
     NEXT
     LAST                        ! size of a row
     s SWAP 2 ->LIST             ! the dimension of the array
     ->ARRY                      ! form the array
  >>
>>
