@@ Matrix C (4 x 5) # 1 2 3 4 5 #====================================== [ 42 0 0 -1 0] [ 123.456 0 3.45E-6 0 0] [ 5.03 +9876 0 0 0] [ -27.3 1%2%3 0 0 0]The example above is specific to writing programs on computers. If you never publish your programs on the web or write programs on the computer for any other reason you can ignore it.
If you were writing the code to generate this matrix into a program you would need to use this line:
[[42,0,0,-1,0],[123.456,0,3.45\exp-6,0,0],[5.03,+9876,0,0,0], [-27.3,1%2%3,0,0,0]] -> Mat C
To directly change one cell in a matrix you need to use a line such as this, which stores 1.23 in the second row, third column:
1.23 -> Mat A[2,3]
The following code for 9x50 calcs uses lists to create such an array:
"HEIGHT"?->H "WIDTH"?->W Seq(0,X,1,H,1->List 1 ; Creates an empty list of length H List->Mat(List 1)->Mat A ; Converts list to single-column matrix in Mat A Mat A ; Stores single-column matrix in Ans matrix For 1->X To W-1 Augment(Mat Ans,Mat A ; Adds another W-1 columns to Ans matrix Next Mat Ans->Mat A ; Stores completed matrix in Mat A. # # Optional lines to free memory: # {0}->List 1 ; Deletes all but one entry from list 1. [[0 ; Deletes copy of Mat A from Ans memory.
77->List 1[5]
Fortunately, there are ways to get around all of these problems, to greatly increase the power of lists as programming tools.
Trn Augment(List->Mat(List 1),[[77->Mat A Mat->List(Mat A,1
This has the disadvantage that it requires a spare matrix, taking up more memory than necessary. Because of this, you may prefer instead to use the following method:
To append 77 to List 1 (sequence method):
1+Dim List 1 Seq(77Int X%Ans + (X<>Ans)List 1[X - (X=Ans, X, 1, Ans, 1->List 1
This has a speed disadvantage when compared to the matrix method however.
To concatenate List 1 and List 2 and store the result in List 3 (matrix method):
Trn Augment(Trn List->Mat(List 1),Trn List->Mat(List 2)->Mat A Mat->List(Mat A,1->List 3
To concatenate List 1 and List 2 and store the result in List 3 (sequence method):
Dim List 1 Seq(List 2[X - Ans + (X<=Ans)(1 - X + Ans](X>Ans) + (X<=Ans)List 1 [X - (X>Ans)(X - 1, X, 1, Ans + Dim List 2, 1->List 3
Seq(77(X=5)+(X<>5)List 1[X - (X > 5, X, 1, Dim List 1 + 1, 1->List 1
Seq(List 1[X+(X>=5, X, 1, Dim List 1 - 1, 1->List 1Note that you can't delete the first item in a list if it is the only item in the list. I must admit that at the moment I can't remember/think how to do that, as I think ClrList clears all lists and { } -> List 1 gives a syntax error. It could be the one thing you can't do with lists... If it is, you might have to keep a dummy value in the first item.
To delete the last item in a list:
Seq(List 1[X, X, 1, Dim List 1 - 1, 1->List 1
Written in notepad and compiled with WTA, for clean, consistent HTML.