hei got a question:
I need an Algorithm. I hab 5 numbers in my list: 1 3 5 7 9. What should i do that these numbers will go backwards? (9 7 5 3 1)
Offline
Q is just a variable.
list is your original list
listB will be the output list (the original list reversed)
Offline
So I have to create 2 lists?
One list with 13579, the other with 97531 ?
Is there any possibility to do that with only 1 list?
Offline
Make a variable called ReplaceNum and do a script like this:
set (ReplaceNum) to (item 1 of list) set (item 1 of list) to (item 5 of list) set (item 5 of list) to (ReplaceNum) set (ReplaceNum) to (item 2 of list) set (item 2 of list) to (item 4 of list) set (item 4 of list) to (ReplaceNum)
Offline
Im from germany(sorry), what means replacenum?
I mean i dont have "set" for my list. theres only insert replace item add delete.
Last edited by alkaidaserg (2009-06-11 14:13:42)
Offline
ReplaceNum = replacement number.
I propose the two lists and two variables method. Your original list is list, your output list is list2. You'd have to create 1 variable - iter, or i (used for making repeat until loop a for loop)
set iter to [1] repeat until <[item (last) from (list2)] = [item (1) from (list)]> replace item (iter) of (list2) with (item (length of (list) - (iter)) change (iter) by (1)
I hope it's readable.
Offline
Thx all!
i finally understood^^ . Now i can do it even with 2 alternatives: First is that I create a new list. I also need a variable. i set variable to 11 and then I change my variable with -2. And this i repeat 5 times so(11-2=9 9-2=5 ...)
Second is SmartIrishKid alternative.
Offline
alkaidaserg wrote:
So I have to create 2 lists?
One list with 13579, the other with 97531 ?
Is there any possibility to do that with only 1 list?
whoops...i meant to attach an image with scripts! i forgot
here it is...i changed the name of the variable to var
these scripts basically do the following:
your original list is ListA
add the reverse of ListA to ListB
copy ListB back to ListA
Last edited by bhz (2009-06-12 07:32:31)
Offline