3 ms·
Works great for trivial cases where there's no interdependency between array elements. As soon as you need to access, for example, adjacent elements, you want t
by mike_hock 4y ago
Works great for trivial cases where there's no interdependency between array elements. As soon as you need to access, for example, adjacent elements, you want to be able to just iterate over 1:length(X) - 1 and access a[i-1] and a[i]. This is the most direct way and thus easiest to get right. Abstractions only make it more error prone.
- mattkrause 4y agoIs `for i in eachindex(X)` really any worse? You can still do math on i, it avoids issues with OffsetArrays, and it might even be clearer why you're iterating. It requires that the array type support linear indexing, but so does doing anything sensible with X[i] and X[i-1].