© Tyl Software Foundation 2019-2021
▶ LIST ASSIGNMENT
Assign a List by Another List
First examples will be with lists that end with plural ending:
as 1 2
ds as
print ds
[ 1, 2 ]
ds
is declared and assigned by as
in the same statement. Upon assignment,
ds
gets all data from as
.
ds
is not connected to as
by any reference, so any changes in one
of them will not affect the other.
Accessing a list that is an item of another list by assignment:
as 1 2
ds <- as
print ds
print as ds 0
print as 0
[ [ 1, 2 ] ]
[ 1, 2 ]
1
[ 1, 2 ]
1
In line
To edit list item of list:
ds <- as
, as
list is added to ds
as its first item. To modify that
item it is needed to assign it to another list. In line as ds 0
, the first
item of ds
, which is a list is assigned to as
list. Now as 0
, will be the
first item of the first item of ds
.
To edit list item of list:
as 1 2
ds <- as
ds <- as
print ds
ms 3 4
ds 1 ms
as ds 0
as 0 10
ds 0 as
print ds
[ [ 1, 2 ], [ 1, 2 ] ]
[ [ 10, 2 ], [ 3, 4 ] ]
[ [ 10, 2 ], [ 3, 4 ] ]
The second item of
The above code with non plural ending variables and square barckets:
ds
was changed to ms
. As before, to edit a list item that
is a list, as
was assigned by ds 0
, then after setting as
, ds 0
was
assigned the updated as
.
The above code with non plural ending variables and square barckets:
adata [ 1 2 ]
ddata [ ]
ddata <- adata
ddata <- adata
print ddata
mdata [ 3 4 ]
ddata 1 mdata
adata ddata 0
adata 0 10
ddata 0 adata
print ddata
All list variables are in declaration lines, and their declaration items are
decorated with square brackets, prior to using them in subsequent
list operations.