Re: compare arrays numbersby ikegami (Pope)
|on Feb 16, 2010 at 18:52 UTC||Need Help??|
To do something to each element of an array, you need a loop over each element of the array. I don't know what's special about for loops that they need to be avoided. Maybe if you told us that, we could help you better.
I wouldn't use a for loop anyway. I'd use a counting loop. The syntax of a counting loop is much simpler than that of a for loop, it's faster do to the much smaller number of opcodes, and it also uses a constant amount of memory. (Mostly for the first reason. The other two are bonuses.)
Counting loop (an optimised form of foreach loop):
Using map like a foreach loop:
Recursion loop, take 2:
Update: Added more alternatives :)