Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
38
Task/Array-length/M2000-Interpreter/array-length.m2000
Normal file
38
Task/Array-length/M2000-Interpreter/array-length.m2000
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
\\ A is a pointer to array
|
||||
A=("Apple", "Orange")
|
||||
Print Len(A)=2 ' True
|
||||
Print Dimension(A, 0) ' LBound (0 or 1), here 0
|
||||
Print Dimension(A) ' No of Dimensions 1
|
||||
Print Dimension(A, 1) ' for 1 dimension array this is also Length=2
|
||||
\\ A$( ) is an Array (not a pointer to array)
|
||||
Dim Base 1, A$(2)
|
||||
A$(1)="Apple", "Orange"
|
||||
Print Dimension(A$(), 0) ' LBound (0 or 1), here 1
|
||||
Print Dimension(A$()) ' No of Dimensions 1
|
||||
Print Dimension(A$(), 1) ' for 1 dimension array this is also Length=2
|
||||
Link A to B$() ' B$() is a reference to A
|
||||
Print B$(0)=A$(1)
|
||||
Print B$(1)=A$(2)
|
||||
Dim C$()
|
||||
\\ C$() get a copy of B$()
|
||||
C$()=B$()
|
||||
Print C$() ' prints Apple Orange
|
||||
\\ An array can link to a new name as reference, and can change major type
|
||||
\\ here A$() get A() so we can read/store numbers and read/store strings in same array
|
||||
\\ using two names
|
||||
Link A$() to A()
|
||||
\\ An array pointer can point to another array
|
||||
A=A()
|
||||
Print Dimension(A, 0) ' LBound (0 or 1), here 1 (was 0)
|
||||
\\ Because B$() is reference of A:
|
||||
Print Dimension(B$(), 0) ' LBound (0 or 1), here 1 (was 0)
|
||||
Print B$(1)=A$(1)
|
||||
Print B$(2)=A$(2)
|
||||
Print Dimension(C$(), 0) ' LBound (0 or 1), here 0
|
||||
\\ change base preserve items
|
||||
Dim Base 1, C$(Dimension(C$(), 1))
|
||||
Print Dimension(C$(), 0) ' LBound (0 or 1), here 1 (was 0)
|
||||
Print C$() ' prints Apple Orange
|
||||
Print Len(C$()) ' Len return all items of an array - can be 0
|
||||
Dim K(1,1,1,1,1,1) ' Maximum 10 dimensions
|
||||
Print Len(K()=1 ' True
|
||||
Loading…
Add table
Add a link
Reference in a new issue