Emptying and Copying Lists [SOLVED]

supremelorax

  • Posts: 24
Greetings,
I am working with lists and am wondering if my understanding of the following functions is correct:
emptylist>deletes all values from list but keeps number of indexes intact
set to copy of list>copies all values from one list to another if set to an existing list

I have two lists; A and B.
A:
0 - 1
1 - 1
2 - 0
3 - 0
4 - 0
5 - 0

B:
0 - 0
1 - 0
2 - 0
3 - 0
4 - 0
5 - 0

If I empty B and set it to a copy of list A, will it look like this?
B:
0 - 1
1 - 1
2 - 0
3 - 0
4 - 0
5 - 0

or this?

B:
0 - 1
1 - 1

or this?
B:
0 - 1
1 - 1
2 -
3 -
4 -
5 -

I appreciate your input.

« Last Edit: June 27, 2020, 04:37:59 pm by supremelorax »

Luyren

  • *
  • Posts: 2245
Greetings,
I am working with lists and am wondering if my understanding of the following functions is correct:
emptylist>deletes all values from list but keeps number of indexes intact
No, it empties the list. There's nothing inside of it, but it's still initialized.

Quote
set to copy of list>copies all values from one list to another if set to an existing list
It doesn't copy the values, it copies the entire list, and set your second one to that copy. If you set one list to another directly, they become one and the same: changes in one affect the other, that's why you usually want to use the copy block.

Quote
I have two lists; A and B.
A:
0 - 1
1 - 1
2 - 0
3 - 0
4 - 0
5 - 0

B:
0 - 0
1 - 0
2 - 0
3 - 0
4 - 0
5 - 0

If I empty B and set it to a copy of list A, will it look like this?
B:
0 - 1
1 - 1
2 - 0
3 - 0
4 - 0
5 - 0
Yes. If you empty or not list B, the result is the same: a copy of list A.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

supremelorax

  • Posts: 24
Thank you. I really appreciate your answer Luyren. By the way I checked out your behaviours and youtube. Thank you for putting so much time into what you do.