Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Arrays and lists (http://www.alice.org/community/showthread.php?t=3983)

REDOS 02-25-2010 10:08 AM

Arrays and lists
 
Hey, do u know if u can move a whole list to one place? ive tried but when i want to make it, i just can move first item, or X item, or final item, not all of them, so i remove the first item i moved with a loop, and repeat the same, but at the end of the day the result is that ive removed all the objetcs i had on the list, and i dont want to make that. thnx

If there is a way to say move item1 &item2&item 3 would be nice

x2495iiii 02-25-2010 10:54 AM

Do you mean clear the list? That's an option if you drag the list onto the scripting area, I believe.

Yep, it's second to last. "Remove all items from <list's name>"

Niteshifter 02-25-2010 12:20 PM

Moving one list to another just requires a single method (as alice can't return a list through a function).

The code would look something like this (this is my own sort of pseudo-code that will make it understandable in Alice):

[CODE]
list1 = [1,2,3]
list2 = []
loop index = 0 up to but not including the size of list1 do
insert item index from list1 to the end of list2
end
remove all items from list1 //remove if you want list1 to keep values
[/CODE]

The output if you look at list1 and list2 will be:

list1 = []
list2 = [1,2,3]

zonedabone 02-26-2010 08:35 PM

1 Attachment(s)
Actually, the "For all in order" function is what you want! It does something to every object in the list! I'll upload a program with it to show you.


All times are GMT -5. The time now is 05:29 AM.

Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.