View Full Version : reverse array...
48design 02-14-2007, 05:00 PM I'm a little bit confused...
Isn't it possible to reverse an array via a simple syntax???
The same problem with copying an array... did not find anything about that in the manual!
for the copy problem I wrote a function, but I could not handle the reverse problem...
fn copy_array array1 array2 = (
for idx = 1 to array2.count do
(
append array1 array2[idx]
)
)
</FONT>
|
|
jonlauf
02-14-2007, 05:49 PM
try these:
array1 = #("A", "B", "C")
array2 = #()
array3 = #()
--copying the array
array2 = for idx in array1 collect idx
--reversing the array
for idx = array1.count to 1 by -1 do (append array3 array1[idx])
MerlinEl
02-14-2007, 05:49 PM
try this:
myArray = #(2,1,3,4,5)
copyArray = #()
join copyArray myArray
Zbuffer
02-14-2007, 06:01 PM
Hi,
if using Max9, you can use DeepCopy
else try this:
-- returns a copy of an array
fn copyArray arr=
(
for i in arr collect i
)
-- returns a reversed copy of an array
fn ReverseArray arr =
(
for i=arr.count to 1 by -1 collect arr[i]
)
Light
02-14-2007, 08:38 PM
for i = arr.count to 1 by -1 collect arr[i]
Light
48design
02-15-2007, 07:50 AM
hey!!
thank you VERY much for all these answers, creative team. :thumbsup:
I don't name a winner, but it's cool to see all these workarounds.
thx!
CGTalk Moderation
02-15-2007, 07:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.