CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-14-2008, 06:35 PM   #1
indestructibleman
New Member
will meyer
technical director
Yozux Studios
Los Angeles, USA
 
Join Date: Apr 2005
Posts: 24
aligning arrays in loops

is there a way to execute a loop with multiple arrays so that $f[0] will correspond with $s[0] and $f[1] will correspond to $s[1], etc . . . ?

for example

Code:
int $first[] = {0,1,2,3,4}; int $second[] = {0,1,2,3,4}; for ($f in $first) for ($s in $second ) { print $f; print ($s + "\n"); }


this returns
Code:
00 01 02 03 04 10 11 12 13 14 etc . . .


could it be made to return only

Code:
00 11 22 33 44

?

thanks,
will
 
Old 02-14-2008, 07:09 PM   #2
Diamant
Frequenter
 
Diamant's Avatar
portfolio
Rich Diamant
Principal Artist
Riot Games
Los Angeles, USA
 
Join Date: Aug 2002
Posts: 161
do a standard loop..

int $first[] = {0, 1, 2, 3, 4};
int $second[] = {0, 1, 2, 3, 4};

int $i = 0;
for ($i: $i < size($first); ++$i)
{
print ($first[$i] + $second[$i] + "\n");
}


-Rich
__________________
Rich Diamant
http://www.rd3d.com
 
Old 02-14-2008, 07:34 PM   #3
indestructibleman
New Member
will meyer
technical director
Yozux Studios
Los Angeles, USA
 
Join Date: Apr 2005
Posts: 24
oh, duh. that makes sense. thanks!
 
Old 02-14-2008, 07:34 PM   #4
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:44 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.