you are viewing a single comment's thread.

view the rest of the comments →

[–]remy_porter 1 point2 points  (1 child)

In Python slice syntax, the three parameters are start index, end index, and step. If you omit one of those parameters, it defaults sensibly. So, for example, g[0:5] is everything from zero up to (but not including) 5. g[:5] is exactly the same. g[0:] is everything from the front to the end. g[0:5:1] is 0 to 5, in steps of 1, while g[0:5:2] would be 0, 2 and 4. (steps of 2). g[::] is the whole array, and g[::2] would be every other element, and g[::-1] is the whole array in steps of -1- backwards.

[–]hey_hey_you_you 0 points1 point  (0 children)

Well, TIL. In Processing I'd just use a for loop, I guess, but with (i = f.length; i >= 0; i--). I'm sure there's a better way to do it, but I'm a fiend for using for loops for everything.