Quote:
Originally Posted by DrakilorP2P
Anyway, similar method, different language but guaranteed to work:
|
No it wouldn't.
If you want to delete stuff in an array part by part you need to start at the end so when you delete the element and the array shrinks in size you're not missing anything. When you're deleting a part from an array everything after it is decreasing in index so the for loop misses the element that replaced the one it just deleted while it moves on to the next highest index.
Also in your Python code the 'cruux' variable is unnecessary. You're taking the length from the 'foo' array and creating a new array from it but not actually using variable 'i', so you should just do
for i in foo:
Edit:
Quote:
Originally Posted by DrakilorP2P
Just noticed my previous post is a really misleading way of deleting half the list.
|
It appears I was the one who was mislead when reading your post. Since I just noticed it was only deleting index 0 and not index
i. If done like that it should work fine I guess.